How to Implement Sweet Alert in Laravel Application

Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

How to Implement Sweet Alert in Laravel Application

In this Post We Will Explain About is How to Implement Sweet Alert in Laravel Application With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to use Sweet Alert to replace standard confirm dialog Example

In this post we will show you Best way to implement Sweet Alert Messages using laravel, hear for Laravel 5 – confirmation box for delete a member from database example with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Read Also:  return view in new tab laravel Example Tutorial

Phase 1: Install uxweb/sweet-alert Package

composer require uxweb/sweet-alert

And then successfully this install package, after that open simple path config/app.php file and pur some service provider and alias source code.config/app.php

'providers' => [
	....
	UxWeb\SweetAlert\SweetAlertServiceProvider::class,
],
'aliases' => [
	....
	'Alert' => UxWeb\SweetAlert\SweetAlert::class,
]

As above We put simple “Alert” facade We can Display, but we do not any external libs require in this best example, so And then We just put for demo.

Phase 2: Add Route

routes/web.php

Route::get('my-livetoaster/{type}', '[email protected]');

Phase 3: Create Controller Method

so open your app/Http/Controllers/LiveController.phpfile and add following route.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class LiveController extends Controller
{
    /**
     * make a new controller instance.
     *
     * devloped by Pakainfo.com @return view
     */
    public function myLivetoaster($type)
    {
        switch ($type) {
            case 'message':
                alert()->message('live Sweet Alert with message Good Luck.');
                break;
            case 'basic':
                alert()->basic('live Sweet Alert with basic Good Luck.','Basic');
                break;
            case 'info':
                alert()->info('live Sweet Alert with info Good Luck.');
                break;
            case 'success':
                alert()->success('some Sweet Alert with success Good Luck.','Welcome to ItSolutionStuff.com')->autoclose(4000);
                break;
            case 'error':
                alert()->error('some Sweet Alert with error Good Luck.');
                break;
            case 'warning':
                alert()->warning('some Sweet Alert with warning Good Luck.');
                break;
            default:
                # your code...
                break;
        }

        return view('my-livetoaster');
    }
}

Phase 4: create Blade File

so open your resources/views/my-livetoaster.blade.phpfile and add following route.

Read Also:  JavaScript String Methods Functions Example

<!DOCTYPE html>
<html>
<head>
	<title>Pakainfo.com Laravel Sweet Alert Notification</title>
	<link rel="stylesheet" href="bootstrap-3.min.css">
	<script src="plugin/jquery.js"></script>
	<link rel="stylesheet" href="sweetalert/1.1.3/sweetalert.min.css" />
	<script src="sweetalert/1.1.3/sweetalert.min.js"></script>
</head>
<body>

<h1 class="text-center">Laravel Sweet Alert Notification step by step</h1>
@include('sweet::alert')
<p>Live24u is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development. We deliver the useful and best tutorials for web professionals — developers, programmers, freelancers and site owners. Any visitors of this site are free to browse our tutorials, live demos and download scripts.</p>
</body>
</html>

And then We are ready to some run our best example therefor run bellow some command run:

Read Also:  Laravel 6 Sweet Alert Tutorial With Example

php artisan serve

And then We can open some bellow url on our browser:

https://www.pakainfo.com/my-livetoaster/success
https://www.pakainfo.com/my-livetoaster/basic
https://www.pakainfo.com/my-livetoaster/message

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Laravel 5 – confirmation box for delete a member from database example And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *