Skip to content
No description or website provided.
PHP HTML
Branch: master
Clone or download
3 authors Configure Renovate (#16)
* Add renovate.json

* Update renovate.json


Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Brian Faust <faustbrian@users.noreply.github.com>
Latest commit f19961b Oct 6, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
resources/views first Nov 4, 2016
src transfer ownership to artisanry Jun 4, 2019
tests
.editorconfig editorconfig Aug 3, 2017
.gitattributes gitattributes Aug 3, 2017
.gitignore first Nov 4, 2016
.travis.yml update deps Jan 29, 2018
LICENSE
README.md MPL 2.0 Jun 9, 2019
composer.json Laravel 6 Aug 28, 2019
phpunit.xml.dist Start to prepare for Laravel 5.5 Jun 5, 2017
renovate.json Configure Renovate (#16) Oct 6, 2019

README.md

Laravel Sweet-Alert

Build Status PHP from Packagist Latest Version License

Installation

Requirements

SweetAlert by t4t5

Require this package, with Composer, in the root directory of your project.

$ composer require artisanry/sweet-alert

And then include the service provider within app/config/app.php.

Artisanry\SweetAlert\SweetAlertServiceProvider::class

Usage

<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Laravel PHP Framework</title>
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/sweetalert/1.0.1/sweetalert.min.css">
    </head>

    <body>
        <div class="container">
            <h1>My Page!</h1>
        </div>

        <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
        <script src="//cdnjs.cloudflare.com/ajax/libs/sweetalert/1.0.1/sweetalert.min.js"></script>
        @include('sweet::alert')
    </body>
</html>

Message (Defaults to Info)

sweet('Welcome aboard!');

return redirect()->route('dashboard');

Success

sweet()->success('You successfully read this important alert message.');

return redirect()->route('dashboard');

Info

sweet()->info('This alert needs your attention, but it\'s not super important.');

return redirect()->route('dashboard');

Warning

sweet()->warning('Better check yourself, you\'re not looking too good.');

return redirect()->route('dashboard');

Error

sweet()->error('Change a few things up and try submitting again.');

return redirect()->route('dashboard');

Build your own Alert

sweet()->config('title', 'Are you sure?')
       ->config('text', 'You will not be able to recover this imaginary file!')
       ->config('type', 'warning')
       ->config('showCancelButton', true)
       ->config('confirmButtonColor', '#DD6B55')
       ->config('confirmButtonText', 'Yes, delete it!')
       ->config('cancelButtonText', 'No, cancel plx!')
       ->config('closeOnConfirm', false)
       ->config('closeOnCancel', false)
       ->config('showConfirmButton', true)
       ->config('timer', null)
       ->callback('function(isConfirm) {
           if (isConfirm) {
               swal("Deleted!", "Your imaginary file has been deleted.", "success");
           } else {
               swal("Cancelled", "Your imaginary file is safe :)", "error");
           }
       }')
       ->commit();

return redirect()->route('dashboard');

Testing

$ phpunit

Security

If you discover a security vulnerability within this package, please send an e-mail to hello@basecode.sh. All security vulnerabilities will be promptly addressed.

Credits

This project exists thanks to all the people who contribute.

License

Mozilla Public License Version 2.0 (MPL-2.0).

You can’t perform that action at this time.