URL::previous PHP Метод

previous() публичный статический Метод

Get the URL for the previous request.
public static previous ( mixed $fallback = false ) : string
$fallback mixed
Результат string
        public static function previous($fallback = false)
        {
            return \Illuminate\Routing\UrlGenerator::previous($fallback);
        }

Usage Example

Пример #1
0
 /**
  * Display the specified resource.
  *
  * @param  NA
  * @return NA
  */
 public function requestLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('user_email' => 'required|email', 'password' => 'required|min:4');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to(URL::previous())->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $user_array = array('user_email' => $this->getInput('user_email', ''), 'password' => $this->getInput('password', ''));
         // attempt to do the login
         if (Auth::attempt($user_array)) {
             $current_password = $this->getInput('password', '');
             // additional validation to make sure that password matched
             $user = Auth::user();
             if (Hash::check($current_password, $user->password)) {
                 return Redirect::intended('check');
             }
         } else {
             Input::flash();
             Session::flash('error_message', 'Invalid email or password, please try again');
             $this->data['has_error'] = ERROR;
             return View::make('session.login')->with('data', $this->data);
         }
     }
 }
All Usage Examples Of URL::previous