Created
November 28, 2012 13:00
-
-
Save ashitvora-zz/4161101 to your computer and use it in GitHub Desktop.
Laravel macro to display flash alert messages
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
/** | |
* 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