<?php

namespace App\Policies;

use App\Admin;
use App\Role;
use Illuminate\Auth\Access\HandlesAuthorization;

class RolePolicy
{
    use HandlesAuthorization;


    public function before(Admin $admin)
    {
        if ($admin->isSuperAdmin()) {
            return true;
        }
    }

    /**
     * Determine whether the user can view the role.
     *
     * @param  \App\User  $admin
     * @param  \App\Role  $role
     * @return mixed
     */
    public function view(Admin $admin, Role $role)
    {
        //
        $admin->hasPermission('role.view');
    }

    /**
     * Determine whether the user can create roles.
     *
     * @param  \App\User  $admin
     * @return mixed
     */
    public function create(Admin $admin)
    {
        //
        return $admin->hasPermission('role.create');
    }

    /**
     * Determine whether the user can update the role.
     *
     * @param  \App\User  $admin
     * @param  \App\Role  $role
     * @return mixed
     */
    public function update(Admin $admin, Role $role)
    {
        //

        return $admin->hasPermission('role.update');
    }

    /**
     * Determine whether the user can delete the role.
     *
     * @param  \App\User  $admin
     * @param  \App\Role  $role
     * @return mixed
     */
    public function delete(Admin $admin, Role $role)
    {
        //
        return $admin->hasPermission('role.delete');
    }
}
