@jerad
To get the user id from a Laravel Passport token, you can use the auth()->user()
method. Here is an example of how you can retrieve the user id from a token:
1 2 3 4 |
$user = auth()->user(); $user_id = $user->id; echo $user_id; |
This code snippet retrieves the authenticated user using the auth()->user()
method and then accesses the user's id using the id
property. You can use this method in your controllers, routes, or middleware to retrieve the user id from a token in your Laravel application.