1. Go to this page and download the library: Download goomcoom/laravel-messages library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// config/goomcoom-laravel-messages.php
return [
/**
* –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
* Bags
* –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
* These are the bags that messages can be added to.
*/
'bags' => [
'error',
'info',
'success',
'warning',
],
];
Messages::add('error', 'Cannot do that!', 'Something went wrong.');
Messages::add('info', 'Something else happened.');
/*
{
...
meta: {
messages: {
error: [
'Cannot do that!',
'Something went wrong.'
],
info: [
'Something else happened.'
]
}
}
}
*/
// Returns Illuminate/Support/MessageBag with "warning" messages
Messages::getBag('warning');
// Removes all messages from the success bag.
Messages::remove('success', '*');
// Removes the "To be removed" & "Also to be removed" messages from the error bag'
Messages::remove('error', 'To be removed', 'Also to be removed');