/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
collect([
'viewRapor',
'manageRapor',
])->each(function ($permission) {
Gate::define($permission, function ($user) use ($permission) {
if ($this->nobodyHasAccess($permission)) {
return true;
}
return $user->hasRoleWithPermission($permission);
});
});
$this->registerPolicies();
//
}`
And Here My Policy.
`class RaporPolicy
{
use HandlesAuthorization;
public function __construct()
{
//
}
public function viewAny($user)
{
return Gate::any(['viewRapor', 'manageRapor'], $user);
}
public function view($user, $post)
{
return Gate::any(['viewRapor', 'manageRapor'], $user, $post);
}
public function create($user)
{
return false;
}
public function update($user, $post)
{
return false;
}
public function delete($user, $post)
{
return false;
}
public function restore($user, $post)
{
return false;
}
public function forceDelete($user, $post)
{
return false;
}
As You Can See In Image Rapor Still Show When I Dont Give Permission.
Here My > AuthServiceProvider.php
` protected $policies = [ ButtonRapor::class => RaporPolicy::class, ];
And Here My Policy. `class RaporPolicy { use HandlesAuthorization;
} `