Laravel 4의 App::error
클래스를 사용하여 응용 프로그램 전체에서 Sentry 예외를 catch하고 withErrors()
함수를 사용하여 데이터를 다시 템플릿에 전달합니다.Laravel 4 'with data persistive
간단한 경로 :
routes.php
Route::post('/login...
...
$credentials = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
$user = Sentry::authenticate($credentials);
// Exception thrown...
그런
는 예외를 잡을 : 뷰에서
exceptions.php
App::error(function(Cartalyst\Sentry\Users\WrongPasswordException $e) {
return Redirect::back()->withErrors(array('failed' => 'Email or password is incorrect'))->withInput();
});
:
을 당신이 시도에서 실패한 로그인 한 후 페이지를 새로 고칠 때/views/login/login.blade.php
@if ($errors->has('failed'))
<strong>{{ $errors->first('failed') }}</strong>
@endif
문제는이러한 오류가 두 번 그들을 볼 수 있도록 유지됩니다. 두 번째 시간 새로 고침, 그들은 지웠다. 입력에 대해 동일하게 적용됩니다 (withInput()
전달).
오류가 경로 내에서 발견되면 (App:error
대신) 모든 것이 정상적으로 작동합니다. App::error
방법을 사용하여 저장된 데이터를 수동으로 지워야합니까?