Last active
November 1, 2019 10:47
-
-
Save ivanmarkovich/cb6b56789ebe8770c9057bf65aeae8eb to your computer and use it in GitHub Desktop.
Put an error to $errors in laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$errors->put('test-error-cat', new Illuminate\Support\MessageBag (["test-error" => [0 => 'error message'],':message'])); | |
$errors->put('test-error-cat', | |
new Illuminate\Support\MessageBag ( | |
[ | |
"test-error" => [0 => 'error message'], | |
':message' | |
] | |
) | |
); | |
// In controller | |
return redirect()->back()->withErrors(["test-error" => [0 => 'error message']]); | |
// In view $errors->all() will return: | |
[0 => 'error message', ...] (foreach allowed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment