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