Here i have a functionality where after a user register to my site it will redirect to path ('user.show').User can also search for another user in the url.If the user exist ('user.show') will provide the requested user's information.But if user search for an invalid name it will provide the current logged in user( the user who is searching ) information.When i attempt for a invalid user i get the error.The error is in the following line
$info=User::where($indicator,'=', Auth::user()->$indicator)->get()->first();
Show() method in user controller :
public function show($user)
{
//
$indicator=is_numeric($user)?'user_id':'username';
$info=User::where($indicator,'=',$user)->get()->first();
if($info){
echo 'bal';
$data=array('info'=>$info);
return View::make('user.show')->with('info',$data);
}else{
echo "this user doesn't exist";
$info=User::where($indicator,'=', Auth::user()->$indicator)->get()->first();
$data=array('info'=>$info);
return View::make('user.show')->with('info',$data);
}
}