Et Cetera

Laravel – Validate Multiple Models and Combine All Error Messages


$validateUser = Validator::make(Input::all(), User::$rules);

$validateRole = Validator::make(Input::all(), Role::$rules);

if ($validateUser->fails() OR $validateRole->fails()) :

$validationMessages = array_merge_recursive($validateUser->messages()->toArray(), $validateRole->messages()->toArray());

return Redirect::back()->withErrors($validationMessages)->withInput();



7 replies on “Laravel – Validate Multiple Models and Combine All Error Messages”

I am interested in the laravel framework , could you please suggest me some reference sites

I am not sure when it was added. But by seeing the docs, it was there already when it was 4.0.
There is so many useful method that Laravel have and little people know about it. Hoping more people will support Laravel.

Comments are closed.