Laravel Toaster Magic, created by Muhammad Rabiul, is a lightweight, powerful, and flexible Toaster package for Laravel applications, designed to enhance user experience with customizable toast notifications.
Features
- Easy-to-Use Toaster Package: Simple and intuitive file management for Laravel.
- RTL Support: Fully compatible with right-to-left (RTL) languages.
- Dark Mode Support: Seamless dark mode for a better user experience.
- Customizable Notifications: Tailor toast messages to fit your application's needs.
To get started with Laravel Toaster Magic in your project, install it via Composer:
composer require devrabiul/laravel-toaster-magic
Next, publish the package resources:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Lastly, in your Blade template, add {!! ToastMagic::styles() !!}
to the <head>
tag and {!! ToastMagic::scripts() !!}
just before the closing </body>
tag. For example:
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page</title> {!! ToastMagic::styles() !!}</head><body> // Your Content {!! ToastMagic::scripts() !!}</body></html>
Within a Controller method, you can then trigger a toast:
use Devrabiul\ToastMagic\Facades\ToastMagic; class TeamController extends Controller{ public function store() { // Your logic ToastMagic::success('Team added successfully!'); return redirect("/teams"); }}
In addition to success
, you can also trigger error
, warning
and info
toasts.
If you need to trigger a toast notification in JavaScript, you can do so as follows:
const toast = new ToastMagic(); // Show a success toasttoast.success("Success!", "Your data has been saved!");
Learn more about this package and view the source code on GitHub.