f1uder/laravel-notification

Laravel Livewire Notification (+ AlpineJS)


Keywords
notification, laravel, livewire, alpinejs, notice, toast-notifications
License
MIT

Documentation

Laravel Livewire Notification (+ AlpineJS)

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Laravel Livewire Notification

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 - default
    • success
  • $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.