✅ UserController (resource controller) ✅ UserPolicy ✅ Маршруты: /admin/users (resource) ✅ Blade-шаблоны: - admin/users/index.blade.php (с фильтрами) - admin/users/create.blade.php - admin/users/edit.blade.php (с группами) - admin/users/show.blade.php ✅ Ссылка в сайдбаре ✅ Привязка к организациям ✅ Распределение по группам ✅ Управление ролями Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
65 lines
1.5 KiB
PHP
Executable File
65 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\User;
|
|
|
|
class UserPolicy
|
|
{
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*/
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return $user->hasRole(['Administrator', 'Manager']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the model.
|
|
*/
|
|
public function view(User $user, User $model): 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, User $model): bool
|
|
{
|
|
return $user->hasRole(['Administrator', 'Manager', 'Curator']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*/
|
|
public function delete(User $user, User $model): bool
|
|
{
|
|
return $user->hasRole(['Administrator']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can restore the model.
|
|
*/
|
|
public function restore(User $user, User $model): bool
|
|
{
|
|
return $user->hasRole(['Administrator']);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can permanently delete the model.
|
|
*/
|
|
public function forceDelete(User $user, User $model): bool
|
|
{
|
|
return $user->hasRole(['Administrator']);
|
|
}
|
|
}
|