check you don't have AUTH_MODEL in your env file as this will take priority
and that your Employee class extends authenticable
I have user model named Employee. I'm using this with Sanctum. This project is an api only, no frontend integration from Laravel. I'm using VS Code. The user global is triggering the ugly red line in VS Code. This typically how I use it:
$user_id = auth()->id();
I have a project where User is the model, and I get no warning. In this project Employee is the user model and I get the warning. In my auth config file, I have:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH_MODEL', App\Models\Employee\Employee::class),
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
I do have a working solution but it's ugly:
/** @var \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard $auth */
$auth = auth();
$user_id = $auth->id();
I've installed the laravel extension into vs code and also tried the ide helper that was recommended, I forget the name now, but it didn't work. I uninstalled the ide helper since it didn't work.
Anyone have a solution for this? Anyone experiencing the same? I really don't want to write the extra code and I won't allow the code to show the warning, even if it works. Any help is appreciated, thank you.
Please or to participate in this conversation.