Authorizing Actions Using Policies: Via Middleware

Via Middleware

Use App\Post;

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

Actions That Don't Require Models

Route::post('/post', function () {
    // The current user may create posts...
})->middleware('can:create,App\Post');

Authorizing Actions Using Policies: Via Middleware — Structure map

Clickable & Draggable!

Authorizing Actions Using Policies: Via Middleware — Related pages: