我正在使用这个伟大的库JWTAuth,我想使用Laravels Auth ::这样的函数..
public function signup(Request $request)
{
// dd(Auth::check());
$all = $request->all();
$rules = [
'first_name' => 'required|min:3',
'last_name' => 'required|min:3',
'email' => 'email|required|max:255|unique:type_user',
'password' => 'required|min:6',
];
if(!Auth::check()){
$validator = Validator::make($request->get('personal_information'), $rules);
if ($validator->fails()) {
return response()->json( $validator->messages() , 422);
}
$personal_information = [
'first_name' => $request['personal_information']['first_name'],
'last_name' => $request['personal_information']['last_name'],
'email' => $request['personal_information']['email'],
'password' => bcrypt($request['personal_information']['password']),
];
$user = User::create($personal_information);
$token = JWTAuth::fromUser($user);
//$authId = Auth::user()->id;
// $authId = $user->id;
unset($all['personal_information']);
}else{
$authId = Auth::user()->id;
}
}
但我似乎无法使Auth :: function起作用。
我在__construct中也有这个:
$this->middleware('jwt.auth', ['except' => ['authenticate','signup']]);
所以我理解,由于signup
被排除在外,因此Auth ::可以使用某些内容。
编辑:我在注册后成功地在另一个控制器方法中使用了Auth :: functions。但如何在注册中使用它?
请说明是否需要更多代码