mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
docs: expand adapter READMEs with comprehensive examples
Each adapter README now includes: - Features section highlighting key capabilities - Installation instructions for Laravel and Symfony - Multiple Quick Start code examples - Configuration options table - Livewire integration with events - Global configuration examples
This commit is contained in:
+119
-10
@@ -1,34 +1,143 @@
|
|||||||
# PHPFlasher Noty Adapter
|
# PHPFlasher Noty Adapter
|
||||||
|
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
[](https://packagist.org/packages/php-flasher/flasher-noty)
|
||||||
|
|
||||||
Noty adapter for [PHPFlasher](https://php-flasher.io).
|
Dependency-free notification library using [Noty](https://ned.im/noty/) for PHPFlasher.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Multiple layout positions (top, bottom, center, corners)
|
||||||
|
- Queue management for multiple notifications
|
||||||
|
- Configurable animations
|
||||||
|
- Action buttons support
|
||||||
|
- Progress bar for timeout
|
||||||
|
- Modal mode support
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
**Laravel:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require php-flasher/flasher-noty-laravel # Laravel
|
composer require php-flasher/flasher-noty-laravel
|
||||||
composer require php-flasher/flasher-noty-symfony # Symfony
|
php artisan flasher:install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require php-flasher/flasher-noty-symfony
|
||||||
|
php bin/console flasher:install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Basic usage
|
// Using the helper function
|
||||||
flash('noty')->success('Operation completed successfully!');
|
noty()->success('Profile updated successfully!');
|
||||||
|
|
||||||
// With options
|
// With custom layout
|
||||||
flash('noty')->warning('Please backup your data.', [
|
noty()->info('New message received', [
|
||||||
'timeout' => 3000,
|
|
||||||
'layout' => 'topCenter',
|
'layout' => 'topCenter',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Error notification
|
||||||
|
noty()->error('Unable to save changes. Please try again.');
|
||||||
|
|
||||||
|
// Warning with custom timeout
|
||||||
|
noty()->warning('Session expires in 5 minutes', [
|
||||||
|
'timeout' => 10000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Sticky notification (no auto-dismiss)
|
||||||
|
noty()->error('Connection lost', ['timeout' => false]);
|
||||||
|
|
||||||
|
// With progress bar
|
||||||
|
noty()->info('Processing...', ['progressBar' => true]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration Options
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `layout` | string | `topRight` | Notification position |
|
||||||
|
| `timeout` | int/bool | `5000` | Auto-dismiss delay in ms (`false` = sticky) |
|
||||||
|
| `progressBar` | bool | `true` | Show countdown progress bar |
|
||||||
|
| `closeWith` | array | `['click']` | How to close (`click`, `button`) |
|
||||||
|
| `animation.open` | string | `null` | Opening animation class |
|
||||||
|
| `animation.close` | string | `null` | Closing animation class |
|
||||||
|
| `modal` | bool | `false` | Show as modal with overlay |
|
||||||
|
| `killer` | bool | `false` | Close all other notifications |
|
||||||
|
|
||||||
|
### Layout Options
|
||||||
|
|
||||||
|
- `top`, `topLeft`, `topCenter`, `topRight`
|
||||||
|
- `center`, `centerLeft`, `centerRight`
|
||||||
|
- `bottom`, `bottomLeft`, `bottomCenter`, `bottomRight`
|
||||||
|
|
||||||
|
## Livewire Integration
|
||||||
|
|
||||||
|
Noty notifications work seamlessly with Livewire. You can listen to notification events:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
|
#[On('noty:click')]
|
||||||
|
public function onNotyClick(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification click
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('noty:close')]
|
||||||
|
public function onNotyClose(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification close
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Events
|
||||||
|
|
||||||
|
| Event | Description |
|
||||||
|
|-------|-------------|
|
||||||
|
| `noty:show` | Fired when notification is shown |
|
||||||
|
| `noty:click` | Fired when notification is clicked |
|
||||||
|
| `noty:close` | Fired when close button is clicked |
|
||||||
|
| `noty:hidden` | Fired when notification is hidden |
|
||||||
|
|
||||||
|
## Global Configuration
|
||||||
|
|
||||||
|
**Laravel** (`config/flasher.php`):
|
||||||
|
|
||||||
|
```php
|
||||||
|
'plugins' => [
|
||||||
|
'noty' => [
|
||||||
|
'options' => [
|
||||||
|
'layout' => 'topRight',
|
||||||
|
'timeout' => 5000,
|
||||||
|
'progressBar' => true,
|
||||||
|
'closeWith' => ['click', 'button'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony** (`config/packages/flasher.yaml`):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flasher:
|
||||||
|
plugins:
|
||||||
|
noty:
|
||||||
|
options:
|
||||||
|
layout: topRight
|
||||||
|
timeout: 5000
|
||||||
|
progressBar: true
|
||||||
|
closeWith: ['click', 'button']
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
For complete documentation, visit [php-flasher.io](https://php-flasher.io).
|
For complete documentation, visit [php-flasher.io/library/noty](https://php-flasher.io/library/noty).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+125
-11
@@ -1,34 +1,148 @@
|
|||||||
# PHPFlasher Notyf Adapter
|
# PHPFlasher Notyf Adapter
|
||||||
|
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
[](https://packagist.org/packages/php-flasher/flasher-notyf)
|
||||||
|
|
||||||
Notyf adapter for [PHPFlasher](https://php-flasher.io).
|
Minimalist, responsive toast notifications using [Notyf](https://github.com/caroso1222/notyf) for PHPFlasher.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Lightweight and minimalist design
|
||||||
|
- Responsive and mobile-friendly
|
||||||
|
- Customizable positions
|
||||||
|
- Dismissible notifications
|
||||||
|
- Ripple effect animation
|
||||||
|
- Custom icons support
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
**Laravel:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require php-flasher/flasher-notyf-laravel # Laravel
|
composer require php-flasher/flasher-notyf-laravel
|
||||||
composer require php-flasher/flasher-notyf-symfony # Symfony
|
php artisan flasher:install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require php-flasher/flasher-notyf-symfony
|
||||||
|
php bin/console flasher:install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Basic usage
|
// Using the helper function
|
||||||
flash('notyf')->success('Operation completed successfully!');
|
notyf()->success('Profile updated successfully!');
|
||||||
|
|
||||||
// With options
|
// With custom position
|
||||||
flash('notyf')->info('New message received', [
|
notyf()->info('New notification', [
|
||||||
'duration' => 4000,
|
'position' => ['x' => 'center', 'y' => 'top'],
|
||||||
'position' => 'top-right',
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Error notification
|
||||||
|
notyf()->error('Unable to save changes.');
|
||||||
|
|
||||||
|
// Custom duration
|
||||||
|
notyf()->warning('Please review your input', [
|
||||||
|
'duration' => 8000,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Dismissible notification
|
||||||
|
notyf()->success('Click to dismiss', [
|
||||||
|
'dismissible' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// With ripple effect
|
||||||
|
notyf()->info('Loading...', ['ripple' => true]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration Options
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `duration` | int | `5000` | Auto-dismiss delay in ms (0 = sticky) |
|
||||||
|
| `dismissible` | bool | `false` | Show close button |
|
||||||
|
| `ripple` | bool | `true` | Enable ripple animation |
|
||||||
|
| `position.x` | string | `right` | Horizontal position (`left`, `center`, `right`) |
|
||||||
|
| `position.y` | string | `top` | Vertical position (`top`, `bottom`) |
|
||||||
|
|
||||||
|
### Position Combinations
|
||||||
|
|
||||||
|
- `{x: 'right', y: 'top'}` (default)
|
||||||
|
- `{x: 'left', y: 'top'}`
|
||||||
|
- `{x: 'center', y: 'top'}`
|
||||||
|
- `{x: 'right', y: 'bottom'}`
|
||||||
|
- `{x: 'left', y: 'bottom'}`
|
||||||
|
- `{x: 'center', y: 'bottom'}`
|
||||||
|
|
||||||
|
## Livewire Integration
|
||||||
|
|
||||||
|
Notyf notifications work seamlessly with Livewire. You can listen to notification events:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
|
#[On('notyf:click')]
|
||||||
|
public function onNotyfClick(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification click
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('notyf:dismiss')]
|
||||||
|
public function onNotyfDismiss(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification dismiss
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Events
|
||||||
|
|
||||||
|
| Event | Description |
|
||||||
|
|-------|-------------|
|
||||||
|
| `notyf:click` | Fired when notification is clicked |
|
||||||
|
| `notyf:dismiss` | Fired when notification is dismissed |
|
||||||
|
|
||||||
|
## Global Configuration
|
||||||
|
|
||||||
|
**Laravel** (`config/flasher.php`):
|
||||||
|
|
||||||
|
```php
|
||||||
|
'plugins' => [
|
||||||
|
'notyf' => [
|
||||||
|
'options' => [
|
||||||
|
'duration' => 5000,
|
||||||
|
'dismissible' => true,
|
||||||
|
'ripple' => true,
|
||||||
|
'position' => [
|
||||||
|
'x' => 'right',
|
||||||
|
'y' => 'top',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony** (`config/packages/flasher.yaml`):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flasher:
|
||||||
|
plugins:
|
||||||
|
notyf:
|
||||||
|
options:
|
||||||
|
duration: 5000
|
||||||
|
dismissible: true
|
||||||
|
ripple: true
|
||||||
|
position:
|
||||||
|
x: right
|
||||||
|
y: top
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
For complete documentation, visit [php-flasher.io](https://php-flasher.io).
|
For complete documentation, visit [php-flasher.io/library/notyf](https://php-flasher.io/library/notyf).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+145
-10
@@ -1,34 +1,169 @@
|
|||||||
# PHPFlasher SweetAlert Adapter
|
# PHPFlasher SweetAlert Adapter
|
||||||
|
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
[](https://packagist.org/packages/php-flasher/flasher-sweetalert)
|
||||||
|
|
||||||
SweetAlert2 adapter for [PHPFlasher](https://php-flasher.io).
|
Beautiful, responsive, customizable alerts using [SweetAlert2](https://sweetalert2.github.io/) for PHPFlasher.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Confirmation dialogs with Confirm/Deny/Cancel buttons
|
||||||
|
- User input dialogs (text, email, password, select, etc.)
|
||||||
|
- Custom HTML content support
|
||||||
|
- Image and icon customization
|
||||||
|
- Toast mode for non-blocking notifications
|
||||||
|
- Timer-based auto-close
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
**Laravel:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require php-flasher/flasher-sweetalert-laravel # Laravel
|
composer require php-flasher/flasher-sweetalert-laravel
|
||||||
composer require php-flasher/flasher-sweetalert-symfony # Symfony
|
php artisan flasher:install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require php-flasher/flasher-sweetalert-symfony
|
||||||
|
php bin/console flasher:install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Basic usage
|
// Using the helper function
|
||||||
flash('sweetalert')->success('Operation completed successfully!');
|
sweetalert()->success('Profile updated successfully!');
|
||||||
|
|
||||||
// With options
|
// With a title
|
||||||
flash('sweetalert')->info('New message', [
|
sweetalert()->info('Please read the terms before continuing', 'Important');
|
||||||
'timer' => 3000,
|
|
||||||
|
// Error notification
|
||||||
|
sweetalert()->error('Unable to process your request.');
|
||||||
|
|
||||||
|
// Toast mode (non-blocking)
|
||||||
|
sweetalert()->success('Saved!', [
|
||||||
'toast' => true,
|
'toast' => true,
|
||||||
|
'position' => 'top-end',
|
||||||
|
'timer' => 3000,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Auto-close with timer
|
||||||
|
sweetalert()->info('Redirecting...', ['timer' => 2000]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Confirmation Dialogs
|
||||||
|
|
||||||
|
```php
|
||||||
|
// Simple confirmation
|
||||||
|
sweetalert()
|
||||||
|
->showDenyButton()
|
||||||
|
->success('Do you want to save the changes?');
|
||||||
|
|
||||||
|
// With all three buttons
|
||||||
|
sweetalert()
|
||||||
|
->showDenyButton(true, 'Don\'t save')
|
||||||
|
->showCancelButton(true, 'Cancel')
|
||||||
|
->warning('Do you want to save the changes?');
|
||||||
|
|
||||||
|
// Delete confirmation
|
||||||
|
sweetalert()
|
||||||
|
->showCancelButton()
|
||||||
|
->confirmButtonColor('#d33')
|
||||||
|
->warning('Are you sure you want to delete this item?', 'This action cannot be undone');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration Options
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `toast` | bool | `false` | Enable toast mode (corner notification) |
|
||||||
|
| `position` | string | `center` | Dialog position on screen |
|
||||||
|
| `timer` | int | `null` | Auto-close delay in ms |
|
||||||
|
| `timerProgressBar` | bool | `false` | Show progress bar for timer |
|
||||||
|
| `showConfirmButton` | bool | `true` | Show confirm button |
|
||||||
|
| `showDenyButton` | bool | `false` | Show deny button |
|
||||||
|
| `showCancelButton` | bool | `false` | Show cancel button |
|
||||||
|
| `confirmButtonText` | string | `OK` | Confirm button text |
|
||||||
|
| `denyButtonText` | string | `No` | Deny button text |
|
||||||
|
| `cancelButtonText` | string | `Cancel` | Cancel button text |
|
||||||
|
|
||||||
|
### Position Options
|
||||||
|
|
||||||
|
- `top`, `top-start`, `top-end`
|
||||||
|
- `center`, `center-start`, `center-end`
|
||||||
|
- `bottom`, `bottom-start`, `bottom-end`
|
||||||
|
|
||||||
|
## Livewire Integration
|
||||||
|
|
||||||
|
SweetAlert works seamlessly with Livewire. You can listen to button click events:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
|
#[On('sweetalert:confirmed')]
|
||||||
|
public function onConfirmed(array $payload): void
|
||||||
|
{
|
||||||
|
// User clicked confirm button
|
||||||
|
$this->performAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('sweetalert:denied')]
|
||||||
|
public function onDenied(array $payload): void
|
||||||
|
{
|
||||||
|
// User clicked deny button
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('sweetalert:dismissed')]
|
||||||
|
public function onDismissed(array $payload): void
|
||||||
|
{
|
||||||
|
// User dismissed the dialog (clicked cancel or outside)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Events
|
||||||
|
|
||||||
|
| Event | Description |
|
||||||
|
|-------|-------------|
|
||||||
|
| `sweetalert:confirmed` | Fired when confirm button is clicked |
|
||||||
|
| `sweetalert:denied` | Fired when deny button is clicked |
|
||||||
|
| `sweetalert:dismissed` | Fired when dialog is dismissed |
|
||||||
|
|
||||||
|
## Global Configuration
|
||||||
|
|
||||||
|
**Laravel** (`config/flasher.php`):
|
||||||
|
|
||||||
|
```php
|
||||||
|
'plugins' => [
|
||||||
|
'sweetalert' => [
|
||||||
|
'options' => [
|
||||||
|
'position' => 'center',
|
||||||
|
'timer' => null,
|
||||||
|
'showConfirmButton' => true,
|
||||||
|
'timerProgressBar' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony** (`config/packages/flasher.yaml`):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flasher:
|
||||||
|
plugins:
|
||||||
|
sweetalert:
|
||||||
|
options:
|
||||||
|
position: center
|
||||||
|
timer: null
|
||||||
|
showConfirmButton: true
|
||||||
|
timerProgressBar: true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
For complete documentation, visit [php-flasher.io](https://php-flasher.io).
|
For complete documentation, visit [php-flasher.io/library/sweetalert](https://php-flasher.io/library/sweetalert).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+124
-11
@@ -1,34 +1,147 @@
|
|||||||
# PHPFlasher Toastr Adapter
|
# PHPFlasher Toastr Adapter
|
||||||
|
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
||||||
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
[](https://packagist.org/packages/php-flasher/flasher-toastr)
|
||||||
|
|
||||||
Toastr adapter for [PHPFlasher](https://php-flasher.io).
|
Toast notifications using [Toastr](https://github.com/CodeSeven/toastr) for PHPFlasher.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Customizable positions (top-right, bottom-left, center, etc.)
|
||||||
|
- Auto-dismiss with configurable timeout
|
||||||
|
- Progress bar support
|
||||||
|
- Close button option
|
||||||
|
- Queue management (newest on top)
|
||||||
|
- Prevent duplicate notifications
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
**Laravel:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require php-flasher/flasher-toastr-laravel # Laravel
|
composer require php-flasher/flasher-toastr-laravel
|
||||||
composer require php-flasher/flasher-toastr-symfony # Symfony
|
php artisan flasher:install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require php-flasher/flasher-toastr-symfony
|
||||||
|
php bin/console flasher:install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```php
|
```php
|
||||||
// Basic usage
|
// Using the helper function
|
||||||
flash('toastr')->success('Operation completed successfully!');
|
toastr()->success('Profile updated successfully!');
|
||||||
|
|
||||||
// With options
|
// With a title
|
||||||
flash('toastr')->info('New message received', [
|
toastr()->info('You have 3 new messages', 'New Messages');
|
||||||
'timeOut' => 5000,
|
|
||||||
'positionClass' => 'toast-top-right',
|
// Error notification
|
||||||
|
toastr()->error('Unable to save changes. Please try again.');
|
||||||
|
|
||||||
|
// Warning with options
|
||||||
|
toastr()->warning('Session expires in 5 minutes', [
|
||||||
|
'timeOut' => 10000,
|
||||||
|
'positionClass' => 'toast-bottom-right',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Sticky notification (won't auto-dismiss)
|
||||||
|
toastr()->error('Connection lost', ['timeOut' => 0]);
|
||||||
|
|
||||||
|
// Prevent duplicate notifications
|
||||||
|
toastr()->success('Saved!', ['preventDuplicates' => true]);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration Options
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `positionClass` | string | `toast-top-right` | Notification position |
|
||||||
|
| `timeOut` | int | `5000` | Auto-dismiss delay in ms (0 = sticky) |
|
||||||
|
| `extendedTimeOut` | int | `1000` | Time after hover before dismiss |
|
||||||
|
| `progressBar` | bool | `true` | Show countdown progress bar |
|
||||||
|
| `closeButton` | bool | `true` | Show close button |
|
||||||
|
| `newestOnTop` | bool | `true` | Stack order for multiple toasts |
|
||||||
|
| `preventDuplicates` | bool | `false` | Prevent duplicate messages |
|
||||||
|
| `tapToDismiss` | bool | `true` | Click toast to dismiss |
|
||||||
|
|
||||||
|
### Position Options
|
||||||
|
|
||||||
|
- `toast-top-right` (default)
|
||||||
|
- `toast-top-left`
|
||||||
|
- `toast-top-center`
|
||||||
|
- `toast-top-full-width`
|
||||||
|
- `toast-bottom-right`
|
||||||
|
- `toast-bottom-left`
|
||||||
|
- `toast-bottom-center`
|
||||||
|
- `toast-bottom-full-width`
|
||||||
|
|
||||||
|
## Livewire Integration
|
||||||
|
|
||||||
|
Toastr notifications work seamlessly with Livewire. You can listen to notification events in your components:
|
||||||
|
|
||||||
|
```php
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
|
#[On('toastr:click')]
|
||||||
|
public function onToastrClick(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification click
|
||||||
|
}
|
||||||
|
|
||||||
|
#[On('toastr:close')]
|
||||||
|
public function onToastrClose(array $payload): void
|
||||||
|
{
|
||||||
|
// Handle notification close
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Events
|
||||||
|
|
||||||
|
| Event | Description |
|
||||||
|
|-------|-------------|
|
||||||
|
| `toastr:show` | Fired when notification is shown |
|
||||||
|
| `toastr:click` | Fired when notification is clicked |
|
||||||
|
| `toastr:close` | Fired when close button is clicked |
|
||||||
|
| `toastr:hidden` | Fired when notification is hidden |
|
||||||
|
|
||||||
|
## Global Configuration
|
||||||
|
|
||||||
|
**Laravel** (`config/flasher.php`):
|
||||||
|
|
||||||
|
```php
|
||||||
|
'plugins' => [
|
||||||
|
'toastr' => [
|
||||||
|
'options' => [
|
||||||
|
'positionClass' => 'toast-top-right',
|
||||||
|
'timeOut' => 5000,
|
||||||
|
'progressBar' => true,
|
||||||
|
'closeButton' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
**Symfony** (`config/packages/flasher.yaml`):
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
flasher:
|
||||||
|
plugins:
|
||||||
|
toastr:
|
||||||
|
options:
|
||||||
|
positionClass: toast-top-right
|
||||||
|
timeOut: 5000
|
||||||
|
progressBar: true
|
||||||
|
closeButton: true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
For complete documentation, visit [php-flasher.io](https://php-flasher.io).
|
For complete documentation, visit [php-flasher.io/library/toastr](https://php-flasher.io/library/toastr).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user