Lager-v3/app/Policies/OtherPolicy.php

46 lines
1.1 KiB
PHP

<?php
namespace App\Policies;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Facades\Auth;
class OtherPolicy
{
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
//
}
public function logs()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','logs_viewAny'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
public function home_page()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','home_page'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
public function statistics()
{
return Auth::user()->role->permissions->contains(Permission::firstWhere('name','=','statistics'))
? Response::allow()
: Response::deny('you are not the chosen one');
}
}