f1uder / laravel-notification
Laravel Livewire Notification (+ AlpineJS)
Installs: 205
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: ^8.0|^8.1
- illuminate/support: ^8.0|^9.0|^10.0
- laravel/framework: ^8.0|^9.0|^10.0
- livewire/livewire: ^2.3|^v2.10
Requires (Dev)
- laravel/pint: ^1.0
This package is auto-updated.
Last update: 2025-02-19 21:33:20 UTC
README
Installation
You can install the package via composer:
composer require f1uder/laravel-notification
Publish the config file with:
php artisan vendor:publish --tag="laravel-notification"
Add css file (notification.css)
@import "../../public/vendor/laravel-notification/css/notification.css"; @tailwind base; @tailwind components; @tailwind utilities;
Add code to template, after body tag
<body> <livewire:laravel-notification.notice/> ... </body>
Usage Laravel
return redirect('/')->notice('message text', 'alert');
return redirect()->route('home')->notice('message text', 'info');
Usage Livewire component
$this->notice('message text', 'alert');
return redirect('/')->notice('message text', 'alert');
Usage alpineJS
$dispatch('notice', {message: 'message text', type: 'alert'});
Arguments
Usage: notice($message, $type, $timer, $title)
$message
- Message.$type
- Notification type.alert
info
- defaultsuccess
$timer
- 3000 default = 3 sec.$title
- Notification header. Default = null.
Config
config/notification.php
$timer
- Notification display time in seconds.$position
- Notification position.tr
- Top right (default).tl
- Top left.br
- Bottom right.bl
- Bottom left.
License
The MIT License (MIT). Please see License File for more information.