Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here

Can feature

If you are running Laravel v8.70, you can chain can() method directly instead of middleware('can:..')

// instead of
Route::get('users/{user}/edit', function (User $user) {
...
})->middleware('can:edit,user');
 
// you can do this
Route::get('users/{user}/edit', function (User $user) {
...
})->can('edit' 'user');
 
// PS: you must write UserPolicy to be able to do this in both cases

Tip given by @sky_0xs

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 67 courses (1172 lessons, total 43 h 18 min)
  • 90 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent New Courses