%PDF- %PDF-
Direktori : /var/www/html/camillo/camillo-api-master/app/Policies/ |
Current File : /var/www/html/camillo/camillo-api-master/app/Policies/IndividualPolicy.php |
<?php namespace App\Policies; use App\Enums\UsertypeEnum; use App\User; use App\Models\Individual; use Illuminate\Auth\Access\HandlesAuthorization; class IndividualPolicy { use HandlesAuthorization; /** * Completely hides the individual. * * @param \App\User $user * @return mixed */ public function viewAny(User $user) { $allowed = [ UsertypeEnum::ADMIN, UsertypeEnum::PRINCIPAL ]; return in_array($user->usertype->role, $allowed); } /** * Determine whether the user can view the individual. * * @param \App\User $user * @param \App\Models\Individual $individual * @return mixed */ public function view(User $user, Individual $individual) { $allowed = [ UsertypeEnum::ADMIN, UsertypeEnum::PRINCIPAL ]; return in_array($user->usertype->role, $allowed); } /** * Determine whether the user can create individuals. * * @param \App\User $user * @return mixed */ public function create(User $user) { $allowed = [ UsertypeEnum::ADMIN, UsertypeEnum::PRINCIPAL ]; return in_array($user->usertype->role, $allowed); } /** * Determine whether the user can update the individual. * * @param \App\User $user * @param \App\Models\Individual $individual * @return mixed */ public function update(User $user, Individual $individual) { $allowed = [ UsertypeEnum::ADMIN, UsertypeEnum::PRINCIPAL ]; return in_array($user->usertype->role, $allowed); } /** * Determine whether the user can delete the individual. * * @param \App\User $user * @param \App\Models\Individual $individual * @return mixed */ public function delete(User $user, Individual $individual) { $allowed = [ UsertypeEnum::ADMIN, UsertypeEnum::PRINCIPAL ]; return in_array($user->usertype->role, $allowed); } /** * Determine whether the user can restore the individual. * * @param \App\User $user * @return mixed */ public function restore(User $user) { return $user->usertype->role === UsertypeEnum::ADMIN; } /** * Determine whether the user can permanently delete the individual. * * @param \App\User $user * @param \App\Models\Individual $individual * @return mixed */ public function forceDelete(User $user, Individual $individual) { return $user->usertype->role === UsertypeEnum::ADMIN; } }