@hadyelmaageny You can try this
$admin = Auth::guard('admin-api')->user(); // For Admin
$user = Auth::guard('api')->user(); // For User
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have two authentication setups in my Laravel application:
Admins: Model: Admin Table: admins Guard: admin-api
Users: Model: User Table: stakeholder_users Guard: api
When an admin logs in, the oauth_access_tokens table correctly stores the user_id of the Admin. However, when I call $user = $request->user();, it retrieves the user from the User model (stakeholder_users table) using the api guard instead of the admin from the admins table using the admin-api guard.
How can I ensure $request->user() correctly retrieves the authenticated admin when using the admin-api guard?
Please or to participate in this conversation.