PHP code example of devrabiul / laravel-toaster-magic

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

    

devrabiul / laravel-toaster-magic example snippets


{!! ToastMagic::styles() !!}

{!! ToastMagic::scripts() !!}

use Devrabiul\ToastMagic\Facades\ToastMagic;

public function store()
{
    // Your logic
    ToastMagic::success('Successfully Created');
    
    // Another Way - message and description
    ToastMagic::success("Success!", "Your data has been saved!");
    
    // Another Way - message and description
    ToastMagic::success("Success!", "Your data has been saved!", [
        'showCloseBtn' => true,
        'customBtnText' => 'Link Text',
        'customBtnLink' => 'https:/demo.com',
    ]);
    return back();
}

// config/laravel-toaster-magic.php

return [
    'options' => [
        // your toast options...
    ],
    'livewire_enabled' => true,
    'livewire_version' => 'v3',
];

$this->dispatch('toastMagic',
    status: 'success',
    title: 'User Created',
    message: 'The user has been successfully created.',
    options: [
        'showCloseBtn' => true,
        'customBtnText' => 'Link Text',
        'customBtnLink' => 'https:/demo.com',
    ],
);

$this->dispatch('toastMagic',
    status: 'info',
    title: 'User Created 2',
    message: 'The user has been successfully created.'
);

// config/laravel-toaster-magic.php

return [
    'options' => [
        // your toast options..
        "theme" => "material", // "default, material".
    ],
    // your toast options..
];

use Devrabiul\ToastMagic\Facades\ToastMagic;

ToastMagic::success('Operation Successful');
ToastMagic::error('Something went wrong');

ToastMagic::dispatch()->success(
    'User Created',
    'The user has been successfully created.',
    [
        'showCloseBtn'    => true,
        'customBtnText'   => 'View Profile',
        'customBtnLink'   => 'https://demo.com',
    ]
);
bash
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"