%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/camillo/camillo-api-master/app/Policies/
Upload File :
Create Path :
Current File : /var/www/html/camillo/camillo-api-master/app/Policies/InstitutePolicy.php

<?php

namespace App\Policies;

use App\Enums\UsertypeEnum;
use App\User;
use App\Models\Institute;
use Illuminate\Auth\Access\HandlesAuthorization;

class InstitutePolicy
{
    use HandlesAuthorization;

    /**
     * Completely hides the institute.
     *
     * @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 institute.
     *
     * @param  \App\User  $user
     * @param  \App\Models\Institute  $institute
     * @return mixed
     */
    public function view(User $user, Institute $institute)
    {
        $allowed = [
            UsertypeEnum::ADMIN,
            UsertypeEnum::PRINCIPAL
        ];
        return in_array($user->usertype->role, $allowed);
    }

    /**
     * Determine whether the user can create institutes.
     *
     * @param  \App\User  $user
     * @return mixed
     */
    public function create(User $user)
    {
        return $user->usertype->role === UsertypeEnum::ADMIN;
    }

    /**
     * Determine whether the user can update the institute.
     *
     * @param  \App\User  $user
     * @param  \App\Models\Institute  $institute
     * @return mixed
     */
    public function update(User $user, Institute $institute)
    {
        $allowed = [
            UsertypeEnum::ADMIN,
            UsertypeEnum::PRINCIPAL
        ];
        return in_array($user->usertype->role, $allowed);
    }

    /**
     * Determine whether the user can delete the institute.
     *
     * @param  \App\User  $user
     * @param  \App\Models\Institute  $institute
     * @return mixed
     */
    public function delete(User $user, Institute $institute)
    {
        return $user->usertype->role === UsertypeEnum::ADMIN;
    }

    /**
     * Determine whether the user can restore the institute.
     *
     * @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 institute.
     *
     * @param  \App\User  $user
     * @param  \App\Models\Institute  $institute
     * @return mixed
     */
    public function forceDelete(User $user, Institute $institute)
    {
        return $user->usertype->role === UsertypeEnum::ADMIN;
    }
}

Zerion Mini Shell 1.0