Hi!
I have the same question. Did you find any solution/ best practice?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I have integrated Sanctum API Authorization for my app (Laravel API + React - as two separated projects) and I have made basic authentication. Now I need to work with roles and permissions. I saw Sanctum have abilities that I can attach to tokens. What is the best way to check abilities before it hit some action? Is there a better way then how its explained in documentation to check in contollers:
if ($user->tokenCan('server:update')) {
//
}
I was looking for solution that Passport has, check on routes:
Route::get('/orders', function () {
// Access token has both "check-status" and "place-orders" scopes...
})->middleware(['auth:api', 'scopes:check-status,place-orders']);
Please or to participate in this conversation.