<?php

namespace App\Policies;

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

class AdminPolicy
{
    use HandlesAuthorization;


    public function before(Admin $admin)
    {
        //die('requested AdminPolicy');
        if ($admin->isSuperAdmin()) {
            return true;
        }
    }

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

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

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

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