CRUD групп - Этап 2

 GroupController (index, create, store, edit, update, destroy)
 GroupPolicy (viewAny, view, create, update, delete)
 Маршруты: /admin/organizations/{organization}/groups (shallow resource)
 Blade-шаблоны:
  - admin/groups/index.blade.php (список групп организации)
  - admin/groups/create.blade.php (форма создания)
  - admin/groups/edit.blade.php (форма редактирования)
 Обновлён admin/organizations/show.blade.php (управление группами)
 Обновлён AuthServiceProvider (регистрация GroupPolicy)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad
2026-03-26 08:53:48 +08:00
co-authored by Qwen-Coder
parent 32fed5d4b6
commit 4f5a615860
8 changed files with 515 additions and 7 deletions
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Policies;
use App\Models\Group;
use App\Models\User;
class GroupPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->hasRole(['Administrator', 'Manager', 'Curator']);
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Group $group): bool
{
return $user->hasRole(['Administrator', 'Manager', 'Curator']);
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->hasRole(['Administrator', 'Manager', 'Curator']);
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Group $group): bool
{
return $user->hasRole(['Administrator', 'Manager', 'Curator']);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Group $group): bool
{
return $user->hasRole(['Administrator', 'Manager']);
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Group $group): bool
{
return $user->hasRole(['Administrator', 'Manager']);
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Group $group): bool
{
return $user->hasRole(['Administrator']);
}
}