-
-
Save kdocki/ccdfacd391b143dbb7f7 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* HTML::show_message_when('first_name', $errors) | |
*/ | |
HTML::macro('show_message_when', function show_message_when($name, $errors, $attributes = array()) | |
{ | |
$attributes_string = ""; | |
$content_string = ""; | |
$attributes['class'] = isset($attributes['class']) ?: ""; | |
$attributes['class'] .= " $name"; | |
if ($errors->has($name)) | |
{ | |
$attributes['class'] .= " alert"; | |
$attributes['class'] .= " alert-danger"; | |
$content_string = $errors->first($name); | |
} | |
foreach ($attributes as $key => $value) { | |
$attributes_string = " $key = \"" . $value . "\""; | |
} | |
return "<div $attributes_string>$content_string</div>"; | |
}); | |
/** | |
* HTML::foreach('user', 'user.itemview', $users) | |
*/ | |
HTML::macro('foreach', function($name, $view, $items) | |
{ | |
var html = ""; | |
foreach ($items as $item) | |
{ | |
html .= View::make($view, [$name => $item]); | |
} | |
return html; | |
}); | |
/** | |
* HTML::not_found($users, 'No users found!') | |
*/ | |
HTML::macro('not_found', function($items, $message = 'None found!') | |
{ | |
return '<div class="empty row">' . $message . '</div>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment