Rashid Ali
2 min readApr 25, 2019

--

Laravel SweetAlert 2 is a Laravel package that integrates the popular JavaScript SweetAlert 2 with Laravel.

Using the package’s Alert facade or alert() helper, you can queue up SweetAlert 2 alerts on the frontend from your controller:

It so easy to implement and easy to use give a shot and leave your thoughts.

Install

To get started with Laravel SweetAlert,
use Composer to add the package to your project's dependencies:

 composer require realrashid/sweet-alert

Alert

  • alert(‘Title’,’Lorem Lorem Lorem’, ‘success’);
  • alert()->success('Title','Lorem Lorem Lorem');
  • alert()->info('Title','Lorem Lorem Lorem');
  • alert()->warning('Title','Lorem Lorem Lorem');
  • alert()->question('Title','Lorem Lorem Lorem');
  • alert()->error('Title','Lorem Lorem Lorem');
  • alert()->html('<i>HTML</i> <u>example</u>'," You can use <b>bold text</b>, <a href='//github.com'>links</a> and other HTML tags ",'success');

Toast

  • toast('Your Post as been submited!','success','top-right');

You can also configure the package’s ToSweetAlert middleware to handle SweetAlert 2 messages during a middleware handler:

public function someFunction(Request $request)
{
return redirect('login')->with('success', 'Login Successfully!');
}

You should check out the Documentation to see what methods are available.
You can learn more about this package and check out the source code on GitHub at realrashid/sweet-alert

Featured On

Laravel News

--

--

Rashid Ali

Creator 0f 9Webb a Full Stack Developer, an Artisan lover. I live in a small town somewhere in the world.I am passionate about Web and Mobile apps development.