Skip to content

Instantly share code, notes, and snippets.

@MarceauKa
Last active March 29, 2019 13:22
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 MarceauKa/11970514bee91deaa68162e224894a96 to your computer and use it in GitHub Desktop.
Save MarceauKa/11970514bee91deaa68162e224894a96 to your computer and use it in GitHub Desktop.
Laravel Blade Errors
<?php
Blade::directive('errormessage', function ($expression) {
return '<?php if ($errors->has(' . $expression . ')): echo \'<span class="help-block">\'.$errors->first(' . $expression . ').\'</span>\'; endif; ?>';
});
Blade::directive('errorexists', function ($expression) {
return '<?= $errors->has(' . $expression . ') ? " has-error" : ""; ?>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment