Actions That Don't Require Models
Like most of the other authorization methods, you may pass a class name to the
@can and @cannot directives if the action does not require a model instance:
@can('create', Post::class)
<!-- The Current User Can Create Posts -->
@endcan
If I put that in my blade create method of the policy does not get executed at all. I had to change Post::class to 'App\Post'. Any ideas why? I would like to use Post::class it looks much better. In my PostController I do import the Post model like use App\Post; Do I need to do something more to be able to use Post:class
It may not work because either the path to your user model is wrong, or you have not added a binding to your AuthServiceProvider.php file, so the permission check will always return false.
You have to use the FQN (fully-qualified name) for the model (App\Post) instead of Post::class because Blade templates are executed in the “global” namespace.