我收到以下错误
ProfileController.php第54行中的ErrorException:未定义的变量:j_request)
第54行的注释如下: (PS:我知道代码不如我所练习的好)
public function getProfile($email)
{
$user = User::where('email',$email)->first();
if(!$user) {
abort(404);
}
$posts = $user->posts()->notReply()->get();
$u_id = $user->id;
$grpusrow = DB::table('grpusrs')
->join('groups', 'grpusrs.group_id', '=', 'groups.id')
->where('grpusrs.user_id', $u_id)
->get();
if(Auth::user() != $user){
$a_user = Auth::user();
$user_id = $a_user->id;
$j_request = DB::table('grpusrs')
->join('groups', 'grpusrs.group_id', '=', 'groups.id')
->where('groups.owner_id', $user_id)
->where('grpusrs.join_request', 1)
->get();
}
return view('profile.index')
->with('user', $user)
->with('posts', $posts)
->with('grp', $grpusrow)
->with('jreq', $j_request) // **This is line 54**
->with('authUserIsFriend', Auth::user()->isFriendWith($user));