Reputation: 5757
How to get Current User Id from posted Passport Auth Token in Laravel. I use
$request->user()->id;
is correct method for get current user id in laravel API
Upvotes: 3
Views: 11657
Reputation: 11
Try this code.
use Auth;
class MyController extends Controller {
public function myFunc(){
dd(Auth::user()->id);
}
}
Upvotes: 1
Reputation: 1789
auth('api')->user()
returns the authenticated user (or null if the user is not logged on) - even if middleware is not used.
Upvotes: 2