Complete the code to enable Sanctum middleware for API routes.
Route::middleware('[1]')->get('/user', function (Request $request) { return $request->user(); });
The middleware auth:sanctum protects API routes using Sanctum tokens.
Complete the code to issue a token for the authenticated user.
$token = $user->createToken('[1]')->plainTextToken;
The createToken method requires a token name, often a descriptive string like 'api-token'.
Fix the error in the middleware registration for Sanctum in the HTTP kernel.
'api' => [ 'throttle:api', '[1]', ],
The Sanctum middleware is auth:sanctum, which must be added to the 'api' middleware group.
Fill both blanks to complete the Sanctum token revocation code.
$user->tokens()->where('[1]', '[2]')->delete();
To revoke a specific token, filter tokens by their name matching the token value, then delete.
Fill all three blanks to complete the middleware and route group setup for Sanctum API authentication.
Route::middleware(['[1]', '[2]'])->prefix('[3]')->group(function () { Route::get('/profile', function () { return auth()->user(); }); });
The route group uses auth:sanctum for authentication, throttle:api for rate limiting, and the prefix api for API routes.