Skip to content

Commit 5269805

Browse files
committed
Initial Commit
0 parents  commit 5269805

File tree

14 files changed

+483
-0
lines changed

14 files changed

+483
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
before_script:
10+
- travis_retry composer self-update
11+
- travis_retry composer install --prefer-source --no-interaction --dev
12+
13+
script: phpunit

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
The MIT License (MIT)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
## SweetAlert 2
2+
Laravel 5 Package for <a href="https://limonte.github.io/sweetalert2/">SweetAlert 2</a>. Use this package to easily show sweetalert2 prompts in your laravel app.
3+
4+
<strong>Installation</strong>
5+
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>
20+
21+
</li>
22+
</ol>
23+
24+
<strong>Config File:</strong>
25+
26+
You can change the basic parameters of the package. Refer the <a href="https://limonte.github.io/sweetalert2/">SweetAlert2</a> Docs for details.
27+
28+
<strong>View Files:</strong>
29+
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.
31+
32+
For Inbuilt views use this in your blade templates before the closing body tag
33+
```php
34+
@include('sweetalert::cdn')
35+
@include('sweetalert::view')
36+
37+
```
38+
39+
Or for the Published Views use this
40+
```php
41+
@include('vendor.sweetalert.cdn')
42+
@include('vendor.sweetalert.view')
43+
```
44+
45+
#Usage
46+
47+
You may use the SWAL Facade or the swal helper function to call the methods.
48+
49+
Showing a Message to User using the SWAL Facade:-
50+
```php
51+
use Softon\SweetAlert\Facades\SWAL;
52+
53+
54+
55+
// Params: [Title,Text,Type,Options[]]
56+
SWAL::message('Good Job','You have successfully Loged In!','info');
57+
SWAL::message('Good Job','You have successfully Loged In!','error');
58+
SWAL::message('Good Job','You have successfully Loged In!','success',['timer'=>2000]);
59+
60+
// For All avialable options please refer the SweetAlert 2 Docs
61+
62+
```
63+
64+
Showing a Message to User using the swal helper function:-
65+
```php
66+
swal('Your Title','Text');
67+
swal()->message('Good Job','You have successfully Loged In!','info');
68+
swal()->message('Good Job','You have successfully Loged In!','error');
69+
swal()->message('Good Job','You have successfully Loged In!','success',['timer'=>2000]);
70+
```
71+
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.:-
73+
```php
74+
// Params [Title, Text, Options]
75+
swal()->warning('Good Job','You have successfully Loged In!',[]);
76+
swal()->error('Good Job','You have successfully Loged In!',[]);
77+
swal()->success('Good Job','You have successfully Loged In!',[]);
78+
swal()->info('Good Job','You have successfully Loged In!',[]);
79+
swal()->question('Good Job','You have successfully Loged In!',[]);
80+
```
81+
82+
To show modal which will autoclose after few seconds:-
83+
```php
84+
swal()->autoclose(2000)->message('Good Job','You have successfully Loged In!','info');
85+
swal()->autoclose(5000)->success('Good Job','You have successfully Loged In!');
86+
```
87+
88+
To show a toast modal which will autoclose after few seconds:-
89+
```php
90+
swal()->toast()->autoclose(2000)->message('Good Job','You have successfully Loged In!','info');
91+
```
92+
93+
To change confirm button text:-
94+
```php
95+
swal()->button('Close Me')->message('Good Job','You have successfully Loged In!','info');
96+
97+
// Button Params [Button Text,Button Colour, SWAL Style Enable / Disable, Style Class for Buttons]
98+
swal()->button('Close Me','#efefef',false,'btn btn-primary')->info('Good Job','You have successfully Loged In!');
99+
```
100+
101+
To change position of the modal:-
102+
```php
103+
// Possible Posions : 'top', 'top-left', 'top-right', 'center', 'center-left', 'center-right', 'bottom', 'bottom-left', or 'bottom-right'
104+
swal()->position('top')->message('Good Job','You have successfully Loged In!','info');
105+
```
106+
107+
You can chain any of these methods to combine the functionality:
108+
109+
```php
110+
swal()->position('bottom-right')->autoclose(3000)->toast()->message('This is A Custom Message');
111+
```

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "softon/sweetalert",
3+
"description": "Laravel 5 Package for SweetAlert2. Use this package to easily show sweetalert2 prompts in your laravel app.",
4+
"license": "MIT",
5+
"keywords": [
6+
"Laravel 5",
7+
"SweetAlert2",
8+
"POPUP BOXES",
9+
],
10+
"authors": [
11+
{
12+
"name": "Shiburaj",
13+
"email": "powerupneo@gmail.com"
14+
}
15+
],
16+
"require": {
17+
"php": ">=5.4.0",
18+
"illuminate/support": "~5.0|~6.0",
19+
"guzzlehttp/guzzle": "~5.0|~6.0"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Softon\\SweetAlert\\": "src/"
24+
},
25+
"files": [
26+
"src/helpers.php"
27+
]
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"Softon\\SweetAlert\\SweetAlertServiceProvider"
33+
],
34+
"aliases": {
35+
"SWAL": "Softon\\SweetAlert\\Facades\\SWAL"
36+
}
37+
}
38+
},
39+
"minimum-stability": "dev"
40+
}

phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Package Test Suite">
15+
<directory suffix=".php">./tests/</directory>
16+
</testsuite>
17+
</testsuites>
18+
</phpunit>

src/Facades/SWAL.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php namespace Softon\SweetAlert\Facades;
2+
3+
use Illuminate\Support\Facades\Facade;
4+
5+
class SWAL extends Facade {
6+
7+
protected static function getFacadeAccessor() { return 'softon.sweetalert'; }
8+
9+
}

0 commit comments

Comments
 (0)