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