🍩 SweetAlert 2 Implementation for Laravel

Overview

Sweetalert Logo

🟣 SweetAlert2 Support for Laravel

Add beautiful alerts by SweetAlert directly into your Laravel application, with a simple setup, and handly helpers.
View Demo · Report Bug · Request Feature

Contributors Forks Stargazers Issues MIT License LinkedIn Twitter

About Sweetalert

Sweetalert is a package for Laravel that allows you to directly interact with SweetAlert. Initially created by uxweb, but now maintained and added support for the latest release of SweetAlert.

We will be releasing some custom alerts within this package in the future, and will continue to maintain the package for future releases of SweetAlert2.

(back to top)

Getting Started

wavey/sweetalert is really simple to set up, If you are familiar with Composer & Laravel, you will most likely know what to do already, however, follow the guide below to get the alerts working and help you make your application look stunning.

Installation

Firstly, require the package into your application through composer using the following command:

composer require wavey/sweetalert

Once you have completed this, run the installer:

php artisan sweetalert:install

This will publish the sweetalert.blade.php file into resources/views/vendor/wavey/sweetalert.

You will now need to require the SweetAlert2 package. The simplest way to achieve this is to include the CDN link, simply add the following link into your layouts.

<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>

Once you have done this, you will need to include the blade file into your layouts, Inside your layout, add:

@include('sweetalert::sweetalert')

Now, you are good to go! Check out the uage section to learn how to show alerts from your controllers.

Through NPM

if you don't want to use the CDN link, you can also include the SweetAlert2 library through NPM.

Install from command line:

If you want to install from your command line, run the following command:

npm install sweetalert2

Then you need to include the library into your javascript, do the following:

// ES6 Modules or TypeScript
import Swal from 'sweetalert2'

// CommonJS
const Swal = require('sweetalert2')

Now compile your assets and include your main javascript file into your views, and you are good to go!

Install from install command (WIP):

You can also install the NPM package through our install command. When installing the package, run the following command instead:

php artisan sweetalert:install --npm

This command will install the NPM package and include inside resources/js/app.js and then run npm run dev to compile your assets.

(back to top)

Usage

We have made Sweetalert very simple to use, firstly, include the library at the top of your controller:

use Wavey\Sweetalert\Sweetalert;

Then, simply call the method you want, below is the methods we support currently:

Sweetalert::basic('Description', 'Title');
Sweetalert::info('Description', 'Title');
Sweetalert::success('Description', 'Title');
Sweetalert::error('Description', 'Title');
Sweetalert::warning('Description', 'Title');
Sweetalert::message('Description', 'Title');
Sweetalert::message('Description <h2>Custom HTML</h2>', 'Title')->html();

We will be releasing support for Toast notifications too, along with some custom alert helpers in the coming releases.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Your Name - @waveygroup - [email protected]

Project Link: https://github.com/waveygroup/sweetalert

(back to top)

Acknowledgments

(back to top)

You might also like...
A simple wallet implementation for Laravel

Laravel Wallet A simple wallet implementation for Laravel. Installation You can install the package via composer: composer require stephenjude/laravel

This is a solution implementation for the coderbyte question, CLEAN GET REQUEST RESULT.

This is a solution implementation for the coderbyte question, CLEAN GET REQUEST RESULT. Two solutions are proposed, the first is a brute force approach while the other is an improved time complexity solution.

Composer repository implementation for ZIPs.

Release Belt — Composer repo for ZIPs Release Belt is a Composer repository, which serves to quickly integrate third–party non–Composer releases into

A lightweight domain event pattern implementation for Doctrine2.
A lightweight domain event pattern implementation for Doctrine2.

Knp Rad Domain Event A lightweight domain event pattern implementation for Doctrine2. Official maintainers: @Einenlum Installation With composer : $ c

PHP implementation of Nanoid, secure URL-friendly unique ID generator

Nanoid-php A tiny (179 bytes), secure URL-friendly unique string ID generator for JavaScript Safe. It uses cryptographically strong random APIs and gu

List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.

What is laravel charts? Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this li

Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Comments
  • Syntax Error

    Syntax Error

    I wrote a simple test in my controller:

     if (session('checked') == 0) {
                Sweetalert::basic('we are checking some details', 'update');
                return redirect()->route('adminHome');
                //return view('admin.dashboard');
            }
    

    and got

    syntax error, unexpected '|', expecting ';' or '{'

    with the error pointing to

    vendor/wavey/sweetalert/src/Notifier.php:111

    Which is highlighting

    `protected function buildJsonConfig(): bool|string

    {
    
        return json_encode( $this->config );
    
    }`
    
    bug 
    opened by jim1506 14
Releases(v1.2.5)
  • v1.2.5(Nov 19, 2022)

    What's Changed

    • 1.2.5: README improvements; Added documentation to functions.php; by @0x35FF in https://github.com/waveygroup/sweetalert/pull/10
    • Apply fixes from StyleCI by @0x35FF in https://github.com/waveygroup/sweetalert/pull/11

    Full Changelog: https://github.com/waveygroup/sweetalert/compare/v1.2.4...v1.2.5

    Source code(tar.gz)
    Source code(zip)
  • v1.2.4(Apr 20, 2022)

  • v1.2.3(Apr 11, 2022)

  • v1.2.2(Apr 8, 2022)

  • v1.2.1(Apr 4, 2022)

  • v1.2.0(Jan 16, 2022)

    Initial Release for Sweetalert.

    Works with SweetAlert2 with the following methods:

    Sweetalert::basic('Description', 'Title');
    Sweetalert::info('Description', 'Title');
    Sweetalert::success('Description', 'Title');
    Sweetalert::error('Description', 'Title');
    Sweetalert::warning('Description', 'Title');
    Sweetalert::message('Description', 'Title');
    Sweetalert::message('Description <h2>Custom HTML</h2>', 'Title')->html();
    

    What's Changed

    • Fixed trailing slash inside composer.json by @0x51D in https://github.com/waveygroup/sweetalert/pull/1
    • v1.0.0 by @0x51D in https://github.com/waveygroup/sweetalert/pull/2
    • v1.1.0: Fixed for SweetAlert2 by @0x51D in https://github.com/waveygroup/sweetalert/pull/3
    • Added new README file; by @0x51D in https://github.com/waveygroup/sweetalert/pull/4

    New Contributors

    • @0x51D made their first contribution in https://github.com/waveygroup/sweetalert/pull/1

    Full Changelog: https://github.com/waveygroup/sweetalert/commits/v1.2.0

    Source code(tar.gz)
    Source code(zip)
Owner
Wavey
👋Wave goodbye to bland branding and make a splash with Wavey 🌊 Glasgow based Creative Agency 👋
Wavey
Implementation Package Spatie/Laravel-Permission

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

M Rizal 3 Sep 12, 2021
A lightway implementation of Laravel's belongs To many

A lightweigth implementation of Laravel's belongs To many relationship in cases you don't need pivot table.

Inani El Houssain 24 Nov 2, 2022
A simple Socialite implementation for Laravel Jetstream.

Introduction Socialstream is a third-party package for Laravel Jetstream. It replaces the published authentication and profile scaffolding provided by

Joel Butcher 334 Jan 2, 2023
An easy-to-use virtual wallet implementation for Laravel

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muath Assawadi 6 Sep 28, 2022
Repository Pattern implementation for Laravel

This is a Simple Repository Pattern implementation for Laravel Projects and an easily way to build Eloquent queries from API requests.

Ephraïm SEDDOR 1 Nov 22, 2021
A Gutenberg implementation for Laravel

Laraberg aims to provide an easy way to integrate the Gutenberg editor with your Laravel projects. It takes the Gutenberg editor and adds all the comm

Van Ons Internet Agency 1.2k Dec 22, 2022
Easy Laravel Server-Side implementation of PrimeVue Datatables

Laravel + PrimeVue Datatables This is a simple, clean and fluent serve-side implementation of PrimeVue Datatables in Laravel. Features Global Search i

Savannabits 11 Dec 29, 2022
Fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent Resources, Translatability, and Swagger.

Laravel Headless What about? This allows a fast and simple implementation of a REST API based on the Laravel Framework, Repository Pattern, Eloquent R

Julien SCHMITT 6 Dec 30, 2022
An easy-to-use virtual wallet implementation for Laravel.

Laravel Wallet Some apps require a prepayment system like a virtual wallet where customers can recharge credits which they can then use to pay in app

Muathye 1 Feb 6, 2022
A straightforward implementation of the Circuit Breaker pattern for Laravel 9

Laravel Circuit Breaker A straightforward implementation of the Circuit Breaker pattern for Laravel Framework 9 (using Memcached). Installation You ca

Leonardo Vieira 2 Mar 22, 2022