代码之家  ›  专栏  ›  技术社区  ›  Rashed Hasan Vijayaragavan

响应内容必须是实现_utoString(),“boolean”的字符串或对象,在laravel 5.4中给出

  •  1
  • Rashed Hasan Vijayaragavan  · 技术社区  · 8 年前

    我在laravel中使用Sentinel包进行高级身份验证。我可以正确注册,但当我要登录时,出现了一个错误,如“响应内容必须是实现\uu toString(),”boolean“given”的字符串或对象。”请任何人帮帮我。

     Route::get('/login', 'LoginController@login');
     Route::post('/login', 'LoginController@postLogin');
    

    下面是我的控制器:

     public function login(){
        return view('authentication.login');
    }
    
    public function postLogin(Request $request){
        Sentinel::authenticate($request->all());
        return Sentinel::check();
    }
    
    3 回复  |  直到 8 年前
        1
  •  1
  •   Imran    8 年前

    __toString() .

    方法您将获得此错误。

    如果你真的想看到 Sentinel::check() 然后你可以使用 dd(Sentinel::check()) 而不是退回。此外,你甚至可以像 ['sentinelCheck' => Sentinel::check()] 如果你真的想。

        2
  •  0
  •   MrChrissss    8 年前

    Sentinel::check()

    https://cartalyst.com/manual/sentinel/2.0#sentinel-check

    您可以使用if语句返回响应:

    if(Sentinel::check()){
        // authenticated
    } else {
        // not authenticated
        return redirect()->back();
    }
    
        3
  •  0
  •   T.Arslan    8 年前

    return ['status' => true, 'msg' => 'mesaj', 'data' => 'datalar'];
    
    推荐文章