Laravel Passport' App \\ User'未找到?

时间:2018-01-22 22:19:34

标签: laravel laravel-passport

我的用户' 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似乎正在寻找' 用户'内部模型' 应用'目录,而不是' 模型'目录,这是正确的地方。

如何解决这个问题?

2 个答案:

答案 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,
    ],
]