PHP code example of valkovic / flash

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

    

valkovic / flash example snippets


'providers' => [
    \Valkovic\Flash\FlashServiceProvider::class,
],

'web' => [
    \Valkovic\Flash\FlashMiddleware::class,
],

'aliases' => [
    'Flash' => Valkovic\Flash\FlashFacade::class,
];

public function store()
{
    flash('Welcome Aboard!');

    return home();
}

flash('Some message','primary',['class'=>'myClass','id'=>'flashMessage']);


flash('Message','success');
Flash()->success('Message');
flash()->success('Message'); //Note that flash() without parameters return Flash Model

// OR INSIDE CLASS
private $flash;
public function __construct(\Valkovic\Flash\Flash $flash) {
    $this->flash = $flash;
}
public function send(User $user) {
    //store User
    $this->flash->success('Message');
}

flash('Message',['class'=>'myClass','id'=>'flashMessage']);
Flash()->message('Message',['class'=>'myClass','id'=>'flashMessage']);

//with template before will produce
<div class="notifications">
        <div class="myClass" id="flashMessage">
            Some message
        </div>
</div>
html
<div class="notifications">
    @foreach($flashes as $flash)
        <div>
            {{$flash->message}}
        </div>
    @endforeach
</div>

<div class="notifications">
    @foreach($flashes as $flash)
        <div {!! $flash->renderProperties() !!}>
            {{$flash->message}}
        </div>
    @endforeach
</div>