laravel请求api出现500错误。

$api->get('user/register', 'AuthController@register');

路由里面用get方式从url获取参数

    public function register(Request $request)
    {
        $newUser = [
            'email' => $request->get('email'),
            'name' => $request->get('name'),
            'password' => bcrypt($request->get('password')),
        ];
        $user = User::create($newUser);
        $token = JWTAuth::fromUser($user);

        return response()->json(compact('token'));
    }
    
    
    {
    "message": "Class 'App\\Api\\Controllers\\User' not found",
    "code": 1,
    "status_code": 500,
    "debug": {
        "line": 45,
        "file": "/Users/nch/code/php/api/app/Api/Controllers/AuthController.php",
        "class": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
        "trace": [
            "#0 {main}"
        ]
    }
}

应该在控制器头部使用:

use App\User;
JellyBool
修改的评论也不能少于六个字哦!
NorthWish
修改的评论也不能少于六个字哦!