PHP code example of mattlibera / livewire-flash

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

    

mattlibera / livewire-flash example snippets


public function store()
{
    flash('Success!');

    return redirect()->back();
}

public function livewireAction()
{
    flash('Your request was successful!')->success()->livewire($this);
}

'styles' => [
    'info' => [
        'bg-color'     => 'bg-blue-100', // could change to bg-purple-100, or something.
        'border-color' => 'border-blue-400',
        'icon-color'   => 'text-blue-400',
        'text-color'   => 'text-blue-800',
        'icon'         => 'fas fa-info-circle', // could change to another FontAwesome icon
    ],

'notice' => [
    'bg-color'     => 'bg-orange-100',
    'border-color' => 'border-orange-400',
    'icon-color'   => 'text-orange-400',
    'text-color'   => 'text-orange-800',
    'icon'         => 'fas fa-flag',
],

'views' => [
    'container' => 'livewire-flash::livewire.flash-container',
    'message'   => 'partials.my-bootstrap-flash',
],

// anywhere
flash('Message 1');
flash('Message 2')->warning();

return redirect('somewhere');

// livewire component
flash('Message 1')->livewire($this);
flash('Message 2')->warning()->livewire($this);

// livewire component
flash('Message 1'); // this one will get lost.
flash('Message 2')->livewire($this); // this one will show on current page via Livewire

bash
php artisan vendor:publish --provider="MattLibera\LivewireFlash\LivewireFlashServiceProvider"
bash
php artisan vendor:publish --provider="MattLibera\LivewireFlash\LivewireFlashServiceProvider"