DEV Community

Rashid Ali
Rashid Ali

Posted on

3 2

Laravel SweetAlert

Laravel SweetAlert

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

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay