| Q | A
| ----------------- | ---
| Bug? | no
| New Feature? | no
| Framework | Laravel
| Framework version | 5.6.18
| Package version | dev-develop
| PHP version | 7.2.3
Use JWT with model APP\Models\CLIENTES
In earlier versions like 0.5.12, in the file APP\config\jwt.php there was an option to customize the model, but in Dev-Develop version there is not option.
@helderferrari2 The key is changing the users provider. You probably changed your config/auth.php as is stated in the docs:
'guards' => [
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
As you can see, the api guard is using the users provider. If you look a little further the config/auth.php file, you will find the providers config. It probably looks like this:
'providers' => [
...
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
],
As you can see the users provider uses the User class as model by default. Change it to your custom class and it should work.
did it work?
Yes it worked perfectly, I used it like this:
In config/auth.php:
'guards' => [
'api' => [
'driver' => 'jwt',
'provider' => 'admins',
],
],
'providers' => [
...
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
],
thank you for your support
@helderferrari2
i got error
"Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in C:\laragon\www\usdimobile\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 123"
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Most helpful comment
@helderferrari2 The key is changing the users provider. You probably changed your config/auth.php as is stated in the docs:
As you can see, the api guard is using the users provider. If you look a little further the config/auth.php file, you will find the providers config. It probably looks like this:
As you can see the users provider uses the User class as model by default. Change it to your custom class and it should work.