Your code looks fine to me. I need a bit more context to figure out what's really going on!
Are you sure the service provider is loaded?
I've been using Policies in Lumen 5.2 and lower before, but now I wanted the use the new 5.3 (beta) version for the new project.
Everything has worked as expected so far, until I started to use Polices for permissions in the same way as I've done before. My Policy classes are never triggered. This is what I've been doing before in 5.2 and before:
// In my controller:
if (Gate::denies('read', $model)) {
return $this->permissionDeniedResponse();
}
//I've also tried:
$this->authorize('read', $model);
//In boot in AuthServiceProvider.php
Gate::policy(\My\Namespace\Models\Order::class, Policies\OrderPolicy::class);
//I've also tried this:
Gate::define('read', function ($user, $post) {
return $user->id == $post->user_id;
});
This worked as expected in Lumen 5.2, but now with 5.3 the Policies are never triggered at all. Any ideas?
Please or to participate in this conversation.