SweetAlert2 Laravel
Install SweetAlert in laravel framework

composer require realrashid/sweet-alert


Add Below line into config/app.php file of providers and aliases

'providers' => [

'aliases' => [
        'Alert' => RealRashid\SweetAlert\Facades\Alert::class,

Apply command php artisan vendor:publish, it will show you some list like below image

SweetAlert2 Laravel 6

I pressed 9 because I have 9th point of providers need to publish just write your provider number publish it

After press enter it will show you some path where this sweetalerts inherited by laravel

Now how to use it?

Suppose in my controller example I'll take here

just defined after namespace this - use RealRashid\SweetAlert\Facades\Alert;
And after then how to use it you can write this alerts into any method like data is updated or deleted or added so that's time you wanna show alert than follow step 5

how to use sweetalert into method of controller?

Alert::success('Portfolio Details', 'added successfully');

just write Alert::success line and now you can use show the sweetalert into your laravel project

There are lots of sweet alerts list, If you want to know about it more you can go here, click on this link - Different SweetAlert List

And if you wanna to see how it is work so as i said you can use my github repository
link is here - sweetalert2 laravel github

That's It

Enjoy code , I hope this way you'll help you for you projects :)

If you like this information you can share , subscribe and comments also how to use sweetalert2 message box in Laravel? blog

Thank you

Post a Comment

Previous Post Next Post