Argument 2 passed to App\Providers\AuthServiceProvider::App\Providers\{closure}() must be an instance of App\Post

I am trying to implement policies in Laravel with the following code

I have a controller to update the Post

And I have the Gate defined in AuthServiceProvider.php

My Route for update the post like this

But when I open the following page http://localhost/dev/cc/laravel/user/public/post/update/1 I am getting the following error

Solution
This is a problem related to the implicit model binding in Laravel. To fix this issue you can do some change to the action in the PostController

Leave a Reply

Your email address will not be published. Required fields are marked *