Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tony98ms/livewire-notification

Laravel package to launch toast notifications.
https://github.com/tony98ms/livewire-notification

Last synced: 5 days ago
JSON representation

Laravel package to launch toast notifications.

Awesome Lists containing this project

README

        

# Laravel package to launch toast notifications.

[![Latest Stable Version](https://img.shields.io/packagist/v/tonystore/livewire-notification?label=version)](https://packagist.org/packages/tonystore/livewire-notification)
[![Packagist Downloads](https://img.shields.io/packagist/dt/tonystore/livewire-notification)](https://packagist.org/packages/tonystore/livewire-notification)
[![License](https://img.shields.io/packagist/l/tonystore/livewire-notification)](https://packagist.org/packages/tonystore/livewire-notification)
[![PHP Version Require](https://img.shields.io/packagist/dependency-v/tonystore/livewire-notification/php)](https://packagist.org/packages/tonystore/livewire-notification)

This package provides assistance when using toast notifications. Using the [iziTOAST](https://izitoast.marcelodolza.com/) package, which allows us to launch elegant and responsive notifications, having the facility to apply a number of configurations that you will find available on their [official site](https://izitoast.marcelodolza.com/) .

## REQUIREMENTS

- [PHP >= 7.2](http://php.net/)
- [Laravel 7|8](https://laravel.com/)
- [Livewire](https://laravel-livewire.com/)
- [iziTOAST](https://izitoast.marcelodolza.com/)

## INSTALLATION VIA COMPOSER

### Step 1: Composer

Run this command line in console.

```sh
composer require tonystore/livewire-notification
```
### Step 2: Include component

Add the [iziTOAST](https://izitoast.marcelodolza.com/) CDN styles and script, and the component containing the script to launch the notifications.

```php


...
@livewireScripts
...


...

//INSERT COMPONENT

//OR

@component('livewire-notification::components.toast') @endcomponent

```

## Publish Config File

```sh
php artisan vendor:publish --provider="Tonystore\LivewireNotification\LivewireNotificationProvider" --tag="config"
```

### Default configuration

```php
//config/livewire-notification

return [
'toast' => [
'title' => '', //Defaut Title
'position' => 'topRight', //Defaut Position
'timeout' => 3000, //Display Time
'modal' => null, //Very important, it defines if an event is triggered to close a Bootstrap modal.
],

```

## Usage

Now, in any Livewire component, you can launch notifications. To launch a notification you can choose between the different types available:
- success
- info
- error
- warning

## Example 1
Launch a simple notification with a personalized message.

```php
$this->alert(
'success',
'Example of notification.',
);

```

## Example 2

Example of notification with modal event.

```php
$this->alert('info','Example of notification with modal event', [
'modal' => '#hideModal'
]
);

```

To use more configurations, you can check the documentation on their [official site](https://izitoast.marcelodolza.com/) .