Skip to content

Instantly share code, notes, and snippets.

@ivanmarkovich
Last active November 1, 2019 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanmarkovich/cb6b56789ebe8770c9057bf65aeae8eb to your computer and use it in GitHub Desktop.
Save ivanmarkovich/cb6b56789ebe8770c9057bf65aeae8eb to your computer and use it in GitHub Desktop.
Put an error to $errors in laravel
$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