$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}"
]
}
}