I've written a simple display_messages()
function that will search Session::get('errors')
for flash data and echo it to the screen.
Where do I put this function? In Codeigniter, you had a helpers folder where you could stick all your little global helper methods.
A flash message is used to communicate back to the user of the website or application that an event has taken place. Often times you'll see a redirect with flash message. This may be something the user intended to do, or it might be something that is just informational.
Basically, helpers in Laravel are built-in utility functions that you can call from anywhere within your application. If the helper you need isn't provided by the core framework, you can code your own helper classes. You'll learn how to create a custom Laravel helper in this tutorial.
As Usman suggested,
class Demo() {
inside it{{ Demo::display() }}
Works because libraries and models are autoloaded in start.php line 76. I believe that filenames must match Classnames (note capital).
<?php
class Demo {
public static function display() {
if( !$message = Session::get('errors'))
$message = 'No Errors';
echo "<pre>print_r($message)</pre>";
}
}
Can't quite figure out why I had a problem using the classname Common, there may be a conflict (you could define a namespace if this were important)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With