uyanik13 / sweet-alert
A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES FOR LARAVEL BY Ogur Uyanik
This package's canonical repository appears to be gone and the package has been frozen as a result.
Fund package maintenance!
Issuehunt
Tidelift
www.buymeacoffee.com/DRO
ko-fi.com/DRO
Installs: 2 625
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 3
Requires
- php: ^7.2|^8.0|^8.1|^8.2
- laravel/framework: ^5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- symfony/thanks: ^1.0
This package is auto-updated.
Last update: 2023-12-11 10:03:27 UTC
README
LARAVEL 6-7-8 Sweet Alert | ALSO FIXED LIVEWIRE INTEGRATION
Install
To get started with SweetAlert2, use Composer to add the package to your project's dependencies:
composer require uyanik13/sweet-alert
Add This Provider to app.php
DRO\SweetAlert\SweetAlertServiceProvider::class,
'providers' => [
/*
* Package Service Providers...
*/
DRO\SweetAlert\SweetAlertServiceProvider::class,
],
Also, add the Alert facade to the aliases array in your app configuration file:
'Alert' => DRO\SweetAlert\Facades\Alert::class,
Include 'sweetalert::alert' in master layout
@include('sweetalert::alert')
and run the below command to publish the package assets.
php artisan sweetalert:publish
Using the Middleware
\DRO\SweetAlert\ToSweetAlert::class,
ENV file
SWEET_ALERT_MIDDLEWARE_AUTO_CLOSE=false
SWEET_ALERT_MIDDLEWARE_TOAST_POSITION='top-end'
SWEET_ALERT_MIDDLEWARE_TOAST_CLOSE_BUTTON=true
SWEET_ALERT_MIDDLEWARE_ALERT_CLOSE_TIME=5000
SWEET_ALERT_AUTO_DISPLAY_ERROR_MESSAGES=true
Examples
public function store(Request $request)
{
//validation
$request->validate([
'title' => 'required|min:3',
'body' => 'required|min:3'
]);
$task = Task::create($request->all());
return redirect('tasks')->with('success', 'Task Created Successfully!');
// OR
return redirect('tasks')->withSuccess('Task Created Successfully!');
}
Livewire Usage
public function submit()
{
$this->alert('success', 'Submission successful!');
}
// Success event
$this->alert('success', 'Submission successful!');
// Information event
$this->alert('info', 'Hello, Awesome Developer!');
// Warning event
$this->alert('warning', 'You have been warned!');
// Error event
$this->alert('error', 'Whoops! you did it again!');
// Success event
$this->alert('success', 'You are successful!', [
'position' => 'center',
'timer' => 15000,
'toast' => false,
'text' => 'I am a subtext',
'showCancelButton' => false,
'showConfirmButton' => false
]);
SweetAlert2 is open-sourced software licensed under the MIT License (MIT). Please see License File for more information.
Made ❤️ with Laravel