Skip to content

Commit

Permalink
Merge pull request #12 from waveygroup/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
0x35FF authored Nov 19, 2022
2 parents 204b8ed + 41d85bd commit 5816f56
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 49 deletions.
100 changes: 52 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
[<img src="https://wavey.group/images/%20sweetalert-small.jpg" />](https://wavey.group)
[<img src="https://wavey.group/images/Ukraine.gif" />](https://ukraine.wavey.group)

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.
## Installation

You can install the package via composer:

```bash
composer require wavey/sweetalert
<p align="center">
<a href="https://wavey.group/packages/sweetalert">
<img alt="Sweetalerts" src="https://i.imgur.com/UVnxkCl.png">
</a>
<br>
<a href="https://img.shields.io/packagist/v/wavey/sweetalert">
<img src="https://img.shields.io/packagist/v/wavey/sweetalert">
</a>
<a href="https://img.shields.io/github/checks-status/waveygroup/sweetalert/master">
<img src="https://img.shields.io/github/checks-status/waveygroup/sweetalert/master">
</a>
<a href="https://img.shields.io/packagist/stars/wavey/sweetalert">
<img src="https://img.shields.io/packagist/stars/wavey/sweetalert">
</a>
<a href="https://img.shields.io/github/issues/waveygroup/sweetalert">
<img src="https://img.shields.io/github/issues/waveygroup/sweetalert">
</a>
<a href="https://img.shields.io/packagist/dependency-v/wavey/sweetalert/php">
<img src="https://img.shields.io/packagist/dependency-v/wavey/sweetalert/php">
</a>
<a href="https://img.shields.io/github/license/waveygroup/sweetalert">
<img src="https://img.shields.io/github/license/waveygroup/sweetalert">
</a>
</p>
<p align="center">
<b>Sweetalerts</b> is an Laravel implementation of the much loved <a href="https://sweetalert2.github.io/">Sweetalerts 2</a> package. Show your users some beautiful alerts when actions are performed in your Laravel application with some handy helpers.
</p>

## ⚡️ Quickstart

Install Sweetalert through composer and run our installer.
```shell
composer require wavey/sweetalert && php artisan sweetalert:install
```

You will then need to run the handy install command

```bash
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.

```html
Include the Sweetalert2 javascript and then include our sweetalert 2 components.
```php
<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:

```html
@include('sweetalert::sweetalert')
```

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

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

Before using Sweetalerts, you will need to include the sweetalert facade at the top of your controllers:
```php
use Wavey\Sweetalert\Sweetalert;
```

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

Now you should have access to the `Sweetalert` facade inside your controllers. Their is many varients of the alerts you can use:
```php
Sweetalert::basic('Description', 'Title');
Sweetalert::info('Description', 'Title');
Expand All @@ -53,24 +58,23 @@ Sweetalert::message('Description', 'Title');
Sweetalert::message('Description <h2>Custom HTML</h2>', 'Title')->html();
```

## Testing

```bash
composer test
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## ⚠️ Limitations
* Currently this package doesn't work as expected from inside Livewire components, we are working on a fix for this and will be inside a later release. |


## Contributing
## 👍 Contribute

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
If you want to say **thank you** and/or support the active development of `Sweetalerts`:

## Security Vulnerabilities
1. Add a [GitHub Star](https://github.com/waveygroup/sweetalert/stargazers) to the project.
2. Tweet about the project on your twitter.
3. Write a review or tutorial on [Medium](https://medium.com/), [Dev.to](https://dev.to/) or personal blog.
4. Support the project by pleding through [GitHub](https://github.com/sponsors/waveygroup).

## 🛡️ Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
Please review our [security policy](https://github.com/waveygroup/sweetalert/security/policy) on how to report security vulnerabilities.

## License
## ⚠️ License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
Copyright (c) 2022-present [Wavey Group](https://github.com/waveygroup) and [Contributors](https://github.com/waveygroup/sweetalert/graphs/contributors). `Sweetalert` is free and open-source software licensed under the [MIT License](https://github.com/waveygroup/sweetalert/blob/master/LICENSE.md).
8 changes: 7 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php

/**
* Add a global helper that will allow the use of sweetalert() throughout the application.
*
* @param string|null $message
* @param string|null $title
*/
if (!function_exists('sweetalert')) {
function sweetalert($message = null, $title = '')
function sweetalert(string $message = null, string $title = '')
{
$notifier = app('wavey.sweetalert');

Expand Down

0 comments on commit 5816f56

Please sign in to comment.