我的用户' model在' App \ Models \ User.php '里面,当我这样做时:
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('POST', 'http://localhost/oauth/token', [
'form_params' => [
'username' => $data['username'],
'password' => $data['password'],
'client_id' => env('PASSWORD_CLIENT_ID'),
'client_secret' => env('PASSWORD_CLIENT_SECRET'),
'grant_type' => 'password'
]
]);
我收到此错误:
"message": "Server error: `POST http://localhost/oauth/token` resulted in a `500 Internal Server Error` response:\nClass 'App\\User' not found\n",
Passport似乎正在寻找' 用户'内部模型' 应用'目录,而不是' 模型'目录,这是正确的地方。
如何解决这个问题?
答案 0 :(得分:1)
在config/auth.php
文件中搜索providers
密钥并将模型从App\User::class
更改为App\Model\User::class
:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Model\User::class, // <-- this line
],
//
],
然后通过php artisan config:clear
删除配置缓存。
答案 1 :(得分:0)
确保更新config/auth.php
文件中的模型类名称:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
]