2017 © Pedro Peláez
 

library sweetalert

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

image

softon/sweetalert

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

  • Friday, March 2, 2018
  • by softon
  • Repository
  • 3 Watchers
  • 15 Stars
  • 5,618 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 6 Forks
  • 3 Open issues
  • 2 Versions
  • 54 % Grown

The README.md

SweetAlert 2

Laravel 5 Package for SweetAlert 2. Use this package to easily show SweetAlert prompts in your Laravel application., (*1)

Installation

  1. Use composer to install the package
$ composer require softon/sweetalert
  1. (Optional for Laravel 5.5) Add the service provider to the config/app.php file in Laravel
Softon\SweetAlert\SweetAlertServiceProvider::class,
  1. (Optional for Laravel 5.5) Add an alias for the Facade to the config/app.php file in Laravel
'SWAL' => Softon\SweetAlert\Facades\SWAL::class,
  1. Publish the config & views by running
$ php artisan vendor:publish

View

This package does have its own views to be included in your templates. But if you would like to tweak it or include your own you can use the views published in the resources/views/vendor/sweetalert directory., (*2)

This package also includes a SweetAlert2 CDN that you can include if you have not included the SweetAlert2 Javascript file from their website. The CDN view must be loaded first., (*3)

For built in views, you can use this in your blade templates before the closing body tag, (*4)

@include('sweetalert::cdn')         // Optional needed only if SweetAlert2 files are not inserted by the developer 
@include('sweetalert::view')
@include('sweetalert::validator')   // Optional needed only to show form validation errors automatically

Or for the Published Views use this, (*5)

@include('vendor.sweetalert.cdn')   // Optional needed only if SweetAlert2 files are not inserted by the developer
@include('vendor.sweetalert.view')
@include('vendor.sweetalert.validator')   // Optional needed only to show form validation errors automatically

Configuration

You can change the basic parameters of the package by referring to the SweetAlert2 documentations for more details., (*6)

Usage

You may use the SWAL Facade or the swal helper function to call the methods., (*7)

Showing a Message to User using the SWAL Facade:, (*8)

use Softon\SweetAlert\Facades\SWAL;  

// Params: [Title,Text,Type,Options[]]
SWAL::message('Good Job','You have successfully logged In!','info');  
SWAL::message('Good Job','You have successfully logged In!','error');  
SWAL::message('Good Job','You have successfully logged In!','success',['timer'=>2000]);

// For All available options please refer the SweetAlert 2 Docs
 ```

Showing a Message to User using the swal helper function:

```php

// Message Type Can be `warning`, `error`, `success`, `info` and `question`. Based on this there are some convinence function that can be used instead of the message method.:
swal('Your Title','Text');
swal()->message('Good Job','You have successfully logged In!','info');  
swal()->message('Good Job','You have successfully logged In!','error');  
swal()->message('Good Job','You have successfully logged In!','success',['timer'=>2000]);
 ```

```php
// Params [Title, Text, Options]
swal()->warning('Good Job','You have successfully logged In!',[]);
swal()->error('Good Job','You have successfully logged In!',[]);
swal()->success('Good Job','You have successfully logged In!',[]);
swal()->info('Good Job','You have successfully logged In!',[]);
swal()->question('Good Job','You have successfully logged In!',[]);

To show modal which will autoclose after few seconds:, (*9)

swal()->autoclose(2000)->message('Good Job','You have successfully logged In!','info'); 
swal()->autoclose(5000)->success('Good Job','You have successfully logged In!'); 

To show a toast modal which will autoclose after few seconds:, (*10)

swal()->toast()->autoclose(2000)->message('Good Job','You have successfully logged In!','info'); 

To change confirm button text:, (*11)

swal()->button('Close Me')->message('Good Job','You have successfully logged In!','info'); 

// Button Params [Button Text,Button Colour, SWAL Style Enable / Disable, Style Class for Buttons]
swal()->button('Close Me','#efefef',false,'btn btn-primary')->info('Good Job','You have successfully logged In!'); 

To change position of the modal:, (*12)

// Possible Positions : `top`, `top-left`, `top-right`, `center`, `center-left`, `center-right`, `bottom`, `bottom-left`, or `bottom-right`
swal()->position('top')->message('Good Job','You have successfully logged In!','info'); 

You can chain any of these methods to combine the functionality:, (*13)

swal()->position('bottom-right')->autoclose(3000)->toast()->message('This is A Custom Message');

The Versions

02/03 2018

dev-master

9999999-dev

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

  Sources   Download

MIT

The Requires

 

by Shiburaj

laravel 5 sweetalert2 popup boxes

03/12 2017

v1.0.1

1.0.1.0

Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.

  Sources   Download

MIT

The Requires

 

by Shiburaj

laravel 5 sweetalert2 popup boxes