Skip to main content
Back to packages
227 GitHub stars

devrabiul/laravel-toaster-magic

View on GitHub

Description

Lightweight, themeable toast package for Laravel & Livewire with no jQuery, Bootstrap, or Tailwind dependency.

1. Controller Usage

Trigger toast notifications from your controllers using the ToastMagic facade:

use Devrabiul\ToastMagic\Facades\ToastMagic;
 
public function store()
{
// Simple message
ToastMagic::success('Successfully Created');
 
// Message with description
ToastMagic::success('Success!', 'Your data has been saved!');
 
// With custom options
ToastMagic::success('Success!', 'Your data has been saved!', [
'showCloseBtn' => true,
'customBtnText' => 'View Record',
'customBtnLink' => 'https://example.com',
]);
 
return back();
}

Available toast types: success, info, warning, error


2. JavaScript Usage

Use ToastMagic directly in JavaScript for AJAX responses or client-side events:

const toastMagic = new ToastMagic();
 
toastMagic.success('Success!', 'Your data has been saved!');
toastMagic.error('Error!', 'Something went wrong.');
toastMagic.warning('Warning!', 'Check your input.', true);
toastMagic.info('Info!', 'Click for details.', false, 'Learn More', 'https://example.com');

Signature: toastMagic.{type}(heading, description, showCloseBtn, customBtnText, customBtnLink)

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.