/** * Check Credentials and Log user In * * @param LoginRequest|Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function post(LoginRequest $request) { $field = filter_var($request->input('credential'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; $request->merge([$field => $request->input('credential')]); if (!$this->auth->attempt($request->only($field, 'password'))) { return redirect()->back()->withInput()->withErrors('Username or Password Not Found'); } /* || $request->get('user_type', '') == 'user'*/ if ($this->auth->user()->is('user')) { return redirect()->route('web.index'); } return redirect()->route('home'); }