PHP code example of hampel / alerts

1. Go to this page and download the library: Download hampel/alerts 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/ */

    

hampel / alerts example snippets


Alert::add('error', 'An error message');

Alert::error('An error message');
Alert::success('Operation succeeded');

Alert::success('auth.login.success');
Alert::error('validation.accepted', array('attribute' => 'terms'));

Alert::add('success', Lang::get('auth.login.success'));
Alert::error(Lang::get('validation.accepted', array('attribute' => 'terms')));

$mybag = new MesageBag();
// add messages to your messagebag

// now get the alert message bag
$alerts = Alert::getMessageBag();

// merge in our messages
$alerts->merge($mybag);

// flash the messages to the session
Alert::flash();

// flash the messages to the session - this is the easiest way to do it
Alert::success('Operation succeeded')->flash();

// alternatively, return a redirect response and let Laravel flash the messages
return Redirect::to('myroute')->with(Alert::getSessionKey(), Alert::error('There was a problem')->getMessageBag()->getMessages());

// you can always just do it all manually and not use the AlertManager at all!
$messages = new MessageBag;
$messages->add('info', Lang::get('something.happened.info'));
Session::flash(Config::get('alerts::session_key', $messages->getMessages());

@
bash
$ php artisan vendor:publish --provider="Hampel\Alerts\AlertServiceProvider"