Skip to content

Commit 97e92d5

Browse files
author
Shiburaj Pappu
authored
Merge pull request #2 from nasrulhazim/master
Added Validator View
2 parents d313c8d + 9d158d4 commit 97e92d5

File tree

7 files changed

+177
-164
lines changed

7 files changed

+177
-164
lines changed

README.md

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,87 @@
11
## SweetAlert 2
2-
Laravel 5 Package for <a href="https://github.com/sweetalert2/sweetalert2/">SweetAlert 2</a>. Use this package to easily show sweetalert2 prompts in your laravel app.
32

4-
<strong>Installation</strong>
3+
Laravel 5 Package for [SweetAlert 2](https://github.com/sweetalert2/sweetalert2/). Use this package to easily show SweetAlert prompts in your Laravel application.
54

6-
<ol>
7-
<li>Use composer to install the package<br>
8-
<pre><code> composer require softon/sweetalert </code></pre>
9-
</li>
10-
<li>(Optional for Laravel 5.5) Add the service provider to the config/app.php file in Laravel<br>
11-
<pre><code> Softon\SweetAlert\SweetAlertServiceProvider::class, </code></pre>
12-
13-
</li>
14-
<li>(Optional for Laravel 5.5) Add an alias for the Facade to the config/app.php file in Laravel<br>
15-
<pre><code> 'SWAL' => Softon\SweetAlert\Facades\SWAL::class, </code></pre>
16-
17-
</li>
18-
<li>Publish the config & views by running <br>
19-
<pre><code> php artisan vendor:publish </code></pre>
5+
### Installation
6+
7+
1. Use composer to install the package
8+
9+
```bash
10+
$ composer require softon/sweetalert
11+
```
12+
13+
2. (Optional for Laravel 5.5) Add the service provider to the config/app.php file in Laravel
14+
15+
```php
16+
Softon\SweetAlert\SweetAlertServiceProvider::class,
17+
```
18+
19+
3. (Optional for Laravel 5.5) Add an alias for the Facade to the config/app.php file in Laravel<br>
20+
21+
```php
22+
'SWAL' => Softon\SweetAlert\Facades\SWAL::class,
23+
```
2024
21-
</li>
22-
</ol>
25+
4. Publish the config & views by running <br>
2326

24-
<strong>Config File:</strong>
27+
```bash
28+
$ php artisan vendor:publish
29+
```
2530

26-
You can change the basic parameters of the package. Refer the <a href="https://github.com/sweetalert2/sweetalert2/">SweetAlert2</a> Docs for details.
31+
### View
2732

28-
<strong>View Files:</strong>
33+
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.
2934

30-
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. 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.
35+
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.
36+
37+
For built in views, you can use this in your blade templates before the closing body tag
3138

32-
For Inbuilt views use this in your blade templates before the closing body tag
3339
```php
34-
@include('sweetalert::cdn')
40+
@include('sweetalert::cdn') // Optional needed only if SweetAlert2 files are not inserted by the developer
3541
@include('sweetalert::view')
36-
42+
@include('sweetalert::validator') // Optional needed only to show form validation errors automatically
3743
```
3844

3945
Or for the Published Views use this
46+
4047
```php
41-
@include('vendor.sweetalert.cdn')
48+
@include('vendor.sweetalert.cdn') // Optional needed only if SweetAlert2 files are not inserted by the developer
4249
@include('vendor.sweetalert.view')
50+
@include('vendor.sweetalert.validator') // Optional needed only to show form validation errors automatically
4351
```
4452

45-
#Usage
53+
### Configuration
54+
55+
You can change the basic parameters of the package by referring to the [SweetAlert2](https://github.com/sweetalert2/sweetalert2/) documentations for more details.
56+
57+
### Usage
4658

4759
You may use the SWAL Facade or the swal helper function to call the methods.
4860

49-
Showing a Message to User using the SWAL Facade:-
61+
Showing a Message to User using the SWAL Facade:
62+
5063
```php
5164
use Softon\SweetAlert\Facades\SWAL;
5265

53-
54-
5566
// Params: [Title,Text,Type,Options[]]
5667
SWAL::message('Good Job','You have successfully logged In!','info');
5768
SWAL::message('Good Job','You have successfully logged In!','error');
5869
SWAL::message('Good Job','You have successfully logged In!','success',['timer'=>2000]);
5970

6071
// For All available options please refer the SweetAlert 2 Docs
61-
6272
```
6373

64-
Showing a Message to User using the swal helper function:-
74+
Showing a Message to User using the swal helper function:
75+
6576
```php
77+
78+
//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.:
6679
swal('Your Title','Text');
6780
swal()->message('Good Job','You have successfully logged In!','info');
6881
swal()->message('Good Job','You have successfully logged In!','error');
6982
swal()->message('Good Job','You have successfully logged In!','success',['timer'=>2000]);
7083
```
7184

72-
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.:-
7385
```php
7486
// Params [Title, Text, Options]
7587
swal()->warning('Good Job','You have successfully logged In!',[]);
@@ -79,31 +91,36 @@ swal()->info('Good Job','You have successfully logged In!',[]);
7991
swal()->question('Good Job','You have successfully logged In!',[]);
8092
```
8193

82-
To show modal which will autoclose after few seconds:-
94+
To show modal which will autoclose after few seconds:
95+
8396
```php
8497
swal()->autoclose(2000)->message('Good Job','You have successfully logged In!','info');
8598
swal()->autoclose(5000)->success('Good Job','You have successfully logged In!');
8699
```
87100

88-
To show a toast modal which will autoclose after few seconds:-
101+
To show a toast modal which will autoclose after few seconds:
102+
89103
```php
90104
swal()->toast()->autoclose(2000)->message('Good Job','You have successfully logged In!','info');
91105
```
92106

93-
To change confirm button text:-
107+
To change confirm button text:
108+
94109
```php
95110
swal()->button('Close Me')->message('Good Job','You have successfully logged In!','info');
96111

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

101-
To change position of the modal:-
102-
```php
116+
To change position of the modal:
117+
103118
// Possible Posions : 'top', 'top-left', 'top-right', 'center', 'center-left', 'center-right', 'bottom', 'bottom-left', or 'bottom-right'
104119
swal()->position('top')->message('Good Job','You have successfully logged In!','info');
105120
```
106121
122+
Possible Positions : `top`, `top-left`, `top-right`, `center`, `center-left`, `center-right`, `bottom`, `bottom-left`, or `bottom-right`
123+
107124
You can chain any of these methods to combine the functionality:
108125
109126
```php

src/Facades/SWAL.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
use Illuminate\Support\Facades\Facade;
44

5-
class SWAL extends Facade {
6-
7-
protected static function getFacadeAccessor() { return 'softon.sweetalert'; }
8-
9-
}
5+
class SWAL extends Facade
6+
{
7+
protected static function getFacadeAccessor()
8+
{
9+
return 'softon.sweetalert';
10+
}
11+
}

0 commit comments

Comments
 (0)