I am using Sentinel package for advanced authentication in laravel. I can register properly, but when I am going to login then here is an error like - 'The Response content must be a string or object implementing __toString(), "boolean" given.' Please anyone help me.
Here is my routes bellow:
Route::get('/login', 'LoginController@login');
Route::post('/login', 'LoginController@postLogin');
Here is my controller bellow:
public function login(){
return view('authentication.login');
}
public function postLogin(Request $request){
Sentinel::authenticate($request->all());
return Sentinel::check();
}
Here is an interesting thing about laravel response. What ever you return from laravel controller as response it tries to convert that array/object into string. But to convert an object into string is possible through the PHP magic method called __toString()
.
As you are not returning an object that has the implementation of __toString()
method you are getting this error.
If you really want to see the output of Sentinel::check()
then you can use dd(Sentinel::check())
instead of returning it. Besides you can even return it like ['sentinelCheck' => Sentinel::check()]
if you really want.