Laravel SweetAlert

Laravel SweetAlert

Laravel SweetAlert 2 is a Laravel package by Rashid Ali 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:

use RealRashid\SweetAlert\Facades\Alert;

Alert::success('Success Title', 'Success Message');
Alert::info('Info Title', 'Info Message');
Alert::warning('Warning Title', 'Warning Message');
Alert::error('Error Title', 'Error Message');

// Using the helper
alert()->success('Title','Lorem Lorem Lorem');
alert()->info('Title','Lorem Lorem Lorem');
alert()->warning('Title','Lorem Lorem Lorem');
alert()->error('Title','Lorem Lorem Lorem');

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!');
}

This package provides some of the boilerplate around integrating SweetAlert in an opinionated way. However, you might want to integrate SweetAlert 2 on your own if you need customizations beyond the scope of what this package’s API provides. 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.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Web Developer
Remote
Livesystems dooh AG
Senior Backend Engineer
Remote
64 Robots
Senior Laravel Developer
Atlanta, GA
Helium LLC
Full-Stack Developer (JS - Vue.js, PHP - Laravel)
US Remote / Telecommute
TTEC Digital
Backend Engineer
Brooklyn, NY
Stationhead
Back-End Developer
Orlando, FL
Christ for all Nations
Senior Software Developer
Nashville, TN
Bernard Health