2026-02-24 11:43:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
|
|
|
use App\Models\SectionApproach;
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use App\Policies\Rules\UserStaticRules;
|
|
|
|
|
|
|
|
|
|
class SectionApproachPolicy
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view any models.
|
|
|
|
|
*/
|
|
|
|
|
public function viewAny(): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::everyOne();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can view the model.
|
|
|
|
|
*/
|
|
|
|
|
public function view(User $authUser): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can create a new model.
|
|
|
|
|
*/
|
|
|
|
|
public function create(User $authUser): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can update the model.
|
|
|
|
|
*/
|
|
|
|
|
public function update(User $authUser, SectionApproach $section_approaches): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine whether the user can delete the model.
|
|
|
|
|
*
|
2026-09-25 16:25:31 +02:00
|
|
|
* @param \App\Models\SectionApproaches $section
|
2026-02-24 11:43:07 +01:00
|
|
|
*/
|
|
|
|
|
public function delete(User $authUser, SectionApproach $section_approaches): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-25 16:25:31 +02:00
|
|
|
/**
|
|
|
|
|
* Determine whether the user can duplicate the model.
|
|
|
|
|
*/
|
2026-02-24 11:43:07 +01:00
|
|
|
public function duplicate(User $authUser): bool
|
|
|
|
|
{
|
|
|
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
|
|
|
}
|
|
|
|
|
}
|