我有ConferencesController
store
方法。在我看来,我发布到conferences.store
并在Redirect::to
方法中执行验证逻辑和store
。
public function store()
{
$validator = Validator::make(Input::all(), Conference::$rules);
if($validator->fails()){
Redirect::back()->with('message', 'Er ging iets mis, zie de errors hieronder.')->withErrors($validator)->withInput();
} else {
$conference = new Conference();
$conference->title = Input::get('title');
$conference->description = Input::get('description');
$conference->location = Input::get('location');
$conference->plannedTime = Input::get('plannedTime');
$conference->save();
}
}
验证可能会失败,或者没有,但控制器不执行Redirect::to
,这是一个已知问题吗?我该如何解决?
答案 0 :(得分:0)
试试这个:
return Redirect::to('/')->with('message', 'Er ging iets mis, zie de errors hieronder')->withErrors($validator)->withInput();