Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Created July 1, 2016 18:52
Show Gist options
  • Save vinicius73/5d2c902f2832c4b69c8733561e5b889e to your computer and use it in GitHub Desktop.
Save vinicius73/5d2c902f2832c4b69c8733561e5b889e to your computer and use it in GitHub Desktop.
<?php
$blade = Blade::getFacadeRoot();
$blade->directive('hasErrorClass', function ($expression) {
return '<?php echo ($errors->has' . $expression . ') ? "has-error" : null; ?>';
});
$blade->directive('errorBlock', function ($expression) {
$name = str_replace(['(', ')'], null, $expression);
return '<?php echo $errors->first(' . $name . ', \'<span class="help-block">:message</span>\') ?>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment