I'm having trouble setting up policy in Laravel. I'm using Laravel voyager admin panel that comes integrated with Laravel policy concept. I have created policy for content model and assigned it to Content BREAD. Just to check the result, I simply returned true in view function. And yet, it still returns false.
Here is a snippet from ContentPolicy class:
/*
* Determine whether the user can view the content.
*
* @param \App\User $user
* @param \App\Content $content
* @return mixed
*/
public function view(User $user, Content $content)
{
return true;
}
and here in ContentController:
public function view(Request $request)
{
$content=Content::all();
return var_dump($this->authorize("view",$content));
}
and here I registered my policy
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
Content::class => ContentPolicy::class
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Passport::routes();
//
}
}
It is worth to note that 'browse_admin' works fine in such case for laravel voyager.
I appreciate your help. Thanks in advance