TIP 22 / 33

Using Gate in Middleware Method.

You can use the gates you specified in App\Providers\AuthServiceProvider in middleware method.

To do this, you just need to put inside the can: and the names of the necessary gates.

php
Route::put('/post/{post}', function (Post $post) {
    // The current user is authorized to update the post.
})->middleware('can:update,post');