模型[App \ Operator]和[App / Nurse]没有查询结果。 Laravel重定向错误

时间:2016-05-17 13:21:48

标签: laravel laravel-5.2

这是一个登录功能,用户根据用户角色登录。

案例1和案例2语句在用户分别登录管理员和医生仪表板的情况下正常工作。

案例3声明适用于护士,他们登录自己的仪表板,但我一直收到错误:

  

“没有模型[App \ Nurse]的查询结果。”

当它重定向到仪表板时,作为操作员仪表板。

public function postSignIn(Request $request) {
    $this->validate($request, [

        'email' => 'required',
        'password' => 'required'

    ]);

   if(Auth::attempt(['email' => $request['email'], 'password' => $request['password']])) {
       $user=User::whereRaw('email=?',[Input::get('email')])->first();

       if($user!=null){
           switch($user->role_id){
               case 1:
                   if($user->status==0){
                       session()->flash('flash_message_error', ' Your Account has been  deactivated. Contact the administrator');
                       return Redirect::to('admin/login');
                   }
                   return redirect()->route("index");
               break;

               case 2:
                   $doctor=Doctor::where('user_id',$user->id)->first();
                   if($user->status==0){
                       session()->flash('flash_message_error', 'Your Account has been deactivated. Contact the administrator');
                       return Redirect::to('admin/login');
                   }
                   return redirect()->route("dashboard")->with(compact('doctor'));
               break;

               case 3:
                   $nur=Nurse::where('user_id',$user->id)->first();
                   if($user->status==0){
                       session()->flash('flash_message_error', 'Your Account has been deactivated. Contact the administrator');
                       return Redirect::to('admin/login');
                   }
                   return redirect()->route("NurseDashboard")->with(compact('nur'));
                   break;


               case 7:
                   $opt = Operate::where('user_id',$user->id)->first();
                   if($user->status==0){
                       session()->flash('flash_message_error', 'Your Account has been deactivated. Contact the administrator');
                       return Redirect::to('admin/login');
                   }
                   return redirect()->route("OperatorDashboard")->with(compact('opt'));

           }
       }
   }
    session()->flash('flash_message_error', 'Incorrect Username/password Combination');
    return redirect()->back();
}

0 个答案:

没有答案