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