PHP code example of cyberpunkcodes / laravel-flashmessages
1. Go to this page and download the library: Download cyberpunkcodes/laravel-flashmessages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cyberpunkcodes / laravel-flashmessages example snippets
\FlashMessages::addFlashMessage(
'success',
'This is a highly configured success message!',
[
// common config options'title' => 'Custom Title',
'class' => 'custom-classname', // if you want to use a different class for this message'icon' => '<i class="fas fa-fw fa-taxi"></i>',// if you want to use a different icon for this message// rare config options (set in default config and rarely have to change)'showIcon' => true, // override the default config values'showTitle' => false, // override the default config values'dismissable' => false, // override the default config values// In the VERY RARE event you need to override the "forced" settings (defined in config)// This allows you to override the override for this individual message itself// very rare config options'forceIcon' => false, // override `forceIcon` (if enabled in config)'forceTitle' => false, // override `forceTitle` (if enabled in config)'forceDismissable' => false, // override `forceDismissable` (if enabled in config)
],
);
publicfunctionredirectTest(\Request $request){
\FlashMessages::addFlashMessage(
'success',
'This is a success message!',
);
\FlashMessages::addFlashMessage(
'warning',
'This is a warning message!',
);
\FlashMessages::addFlashMessage(
'info',
'This is an info message!',
);
\FlashMessages::addFlashMessage(
'error',
'This is an error message!',
[
'title' => 'Custom Error Title',
'dismissable' => false,
]
);
// Let's also ensure a message with an undefined type looks fine while we are here
\FlashMessages::addFlashMessage(
'foo', // some type that does not exist, falls back to default class/icon'This is an error message!',
);
return redirect()->route('home'); // change home to whatever named route you need (ie: dashboard)
}