Skip to content

Instantly share code, notes, and snippets.

@ashitvora-zz
Created November 28, 2012 13:00
Show Gist options
  • Save ashitvora-zz/4161101 to your computer and use it in GitHub Desktop.
Save ashitvora-zz/4161101 to your computer and use it in GitHub Desktop.
Laravel macro to display flash alert messages
/**
* Display Error / Success / Warn / Info messages
*
* These messages are set using Session::flash(<message_type>, <message>);
*/
HTML::macro("alert", function(){
$alerts = array();
$alert_types = array("error", "success", "warn", "info");
foreach ($alert_types as $type) {
if( Session::has($type) ){
array_push($alerts, '<div class="alert alert-'. $type .'">');
array_push($alerts, '<button type="button" class="close" data-dismiss="alert">x</button>');
array_push($alerts, Session::get($type) );
array_push($alerts, '</div>');
}
}
return implode("", $alerts);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment