@flash() is a shorthand directive for Res::flash();
method. When a flash notification message is set, this directive makes it easier to fetch the flash message
once before it is finally removed. Every notification message is defined by
its unique notification key that is used to access the message.
<php?
namespace spoova\mi\windows\Routes
use Window;
class Home extends Window {
function __construct() {
if($logged_in) {
// $logged_in as some incoming database response
Res::setFlash('account', 'user logged in');
header('location:'.domurl('dashboard'));
}
self::call($this, [lastUrl() => 'home']);
}
function home() {
self::load('home', fn() => compile ()) ;
}
}
account in the
Home route. Assuming we have another route
Dashboard that renders a dashboard.rex.php
template file, when the user logs in, the redirection is made from Home to
Dashboard route which renders a dashboard.rex.php template file.
From the template file, we can apply the directive as shown below:
<div>
@flash('account')
</div>
dashboard web page just as shown below:
<div>
user logged in
</div>
<div>
@flash('account', 'custom message here')
</div>
Notice class.