A powerful and flexible Toaster package for Laravel applications, designed to enhance user experience with customizable toast notifications.
To get started with ToastMagic, follow these simple steps:
Install the package via Composer:
composer require devrabiul/laravel-toaster-magic
Publish the package resources by running:
php artisan vendor:publish --provider="Devrabiul\ToastMagic\ToastMagicServiceProvider"
Integrate ToastMagic into your Blade template by adding the following includes:
Add the styles in your <head>
section:
{!! ToastMagic::styles() !!}
Add the scripts before the closing <body>
tag:
{!! ToastMagic::scripts() !!}
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>
You can trigger toast notifications from your Laravel controller using the ToastMagic
facade.
use Devrabiul\ToastMagic\Facades\ToastMagic;
class LanguageController extends Controller
{
public function add()
{
// Your logic
ToastMagic::success('Successfully Updated');
return back();
}
}
const toastMagic = new ToastMagic();
// Show a success toast
toastMagic.success("Success!", "Your data has been saved!");
// Show an error toast
toastMagic.error("Error!", "Something went wrong.");
// Show a warning toast with a close button
toastMagic.warning("Warning!", "Please check your input.", true);
// Show an info toast with a custom button
toastMagic.info("Info!", "Click below for more details.", false, "Learn More", "https://example.com");
You can configure the position of the toast notifications using the following options:
Position | Description |
---|---|
toast-top-start |
Displays toast in the top left corner. |
toast-top-end |
Displays toast in the top right corner. |
toast-bottom-start |
Displays toast in the bottom left corner. |
toast-bottom-end |
Displays toast in the bottom right corner. |
toast-top-center |
Displays toast at the top center. |
toast-bottom-center |
Displays toast at the bottom center. |
Experience the magic of ToastMagic and enhance your Laravel applications with elegant toast notifications.
š GitHub: Laravel Toaster Magic
š Website: laravel-toaster-magic.rixetbd.com
š Packagist: https://packagist.org/packages/devrabiul/laravel-toaster-magic
We welcome contributions to ToastMagic! If you would like to contribute, please fork the repository and submit a pull request. For any issues or feature requests, please open an issue on GitHub.
This package is open-sourced software licensed under the MIT license.
For support or inquiries, please reach out to us at Send Mail.