本文整理汇总了PHP中app\Profile::byuser_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::byuser_id方法的具体用法?PHP Profile::byuser_id怎么用?PHP Profile::byuser_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Profile
的用法示例。
在下文中一共展示了Profile::byuser_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login_profile
/**
* Login and return profile data
*
* @param Request $request
* @return Response
*/
public function login_profile(Request $request)
{
$credentials = $request->only('email', 'password');
//$credentials = $request->all();
try {
// attempt to verify the credentials and create a token for the user
if (!($token = JWTAuth::attempt($credentials))) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
//dd($token);
// something went wrong whilst attempting to encode the token
return response()->json(['error' => 'could_not_create_token'], 500);
}
//dd($token);
// the token is valid and we have found the user
$user = Auth::user();
try {
$profile = Profile::byuser_id($user->id)->firstOrFail();
//$industry = [$profile->industry->slug, $profile->industry->name];
//return response()->json(compact('token', 'profile', 'industry'));
return response()->json(compact('token', 'profile'));
} catch (ModelNotFoundException $e) {
return response()->json(['error' => 'profile does not exist'], 404);
}
}