|
1 |
| -Laravel Notify |
2 |
| -====== |
3 |
| - |
4 |
| -Elegant notifications to laravel with [Toastr](https://github.com/CodeSeven/toastr) or [PNotify](https://github.com/sciactive/pnotify) |
5 |
| - |
6 |
| -Installation |
7 |
| ------------- |
8 |
| - |
9 |
| -1. Either run `composer require helmesvs/laravel-notify` or add `"helmesvs/laravel-notify"` to the `require` key in `composer.json` and run `composer install`. |
10 |
| -2. Add `Helmesvs\Notify\NotifyServiceProvider::class,` to the `providers` key in `config/app.php`. |
11 |
| -3. Add `'Notify' => Helmesvs\Notify\Facades\Notify::class,` to the `aliases` key in `config/app.php`. |
12 |
| -4. Run `php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify"` to publish the config file. |
13 |
| -5. Include the output `{!! Notify::render() !!}` in your master view template. |
14 |
| -6. *Optional*: Modify the configuration file located in config/notify.php. |
15 |
| - |
16 |
| -Usage |
17 |
| ------ |
18 |
| - |
19 |
| -Call one of these methods in your controllers to insert a notification: |
20 |
| - - `Notify::warning($message, $title = null, $options = [])` - add a warning notification |
21 |
| - - `Notify::error($message, $title = null, $options = [])` - add an error notification |
22 |
| - - `Notify::info($message, $title = null, $options = [])` - add an info notification |
23 |
| - - `Notify::success($message, $title = null, $options = [])` - add a success notification |
24 |
| - - `Notify::add($type: warning|error|info|success, $message, $title = null, $options = [])` - add a notification |
25 |
| - - **`Notify::clear()` - clear all current notification** |
26 |
| - |
27 |
| -Configuration |
28 |
| -------------- |
29 |
| - |
30 |
| -Open `config/notify.php` to adjust package configuration. If this file doesn't exist, run `php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify"` to create the default configuration file. |
31 |
| - |
32 |
| - |
33 |
| -### General Options |
34 |
| -``` php |
35 |
| -'options' => [ |
36 |
| - 'lib' => 'toastr', |
37 |
| - 'style' => 'custom' |
38 |
| -] |
39 |
| -``` |
40 |
| - |
41 |
| -Set `'lib'` as `toastr` to use [toastr.js](https://github.com/CodeSeven/toastr) or `pnotify` to use [pnotify.js](https://github.com/sciactive/pnotify). |
42 |
| - |
43 |
| -Set `'style'` to `'custom'` to use custom settings, or as `'default'` to default library settings. |
44 |
| - |
45 |
| -The style of notifications can be customized in `public/vendor/Notify/style.css`. |
46 |
| - |
47 |
| -### Options Toastr |
48 |
| -``` php |
49 |
| -'ToastrOptions' => [ |
50 |
| - "closeButton" => false, |
51 |
| - "closeHtml" => '', |
52 |
| - "newestOnTop" => true, |
53 |
| - "progressBar" => false, |
54 |
| - ... |
55 |
| -] |
56 |
| -``` |
57 |
| - |
58 |
| -### Options PNotify |
59 |
| -``` php |
60 |
| -'PNotifyOptions' => [ |
61 |
| - 'title_escape' => false, |
62 |
| - 'text_escape' => false, |
63 |
| - 'styling' => 'brighttheme', |
64 |
| - 'addclass' => '', |
65 |
| - ... |
66 |
| -] |
67 |
| -``` |
68 |
| - |
69 |
| -For a list of available options, see [toastr.js' documentation](https://github.com/CodeSeven/toastr) and [pnotify.js' documentation](https://github.com/sciactive/pnotify). |
| 1 | +Laravel Notify |
| 2 | +====== |
| 3 | + |
| 4 | +Elegant notifications to laravel with [Toastr](https://github.com/CodeSeven/toastr) or [PNotify](https://github.com/sciactive/pnotify) |
| 5 | + |
| 6 | +Installation |
| 7 | +------------ |
| 8 | + |
| 9 | +1. Either run `composer require helmesvs/laravel-notify` or add `"helmesvs/laravel-notify"` to the `require` key in `composer.json` and run `composer install`. |
| 10 | +2. Add `Helmesvs\Notify\NotifyServiceProvider::class,` to the `providers` key in `config/app.php`. |
| 11 | +3. Add `'Notify' => Helmesvs\Notify\Facades\Notify::class,` to the `aliases` key in `config/app.php`. |
| 12 | +4. Run `php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify"` to publish the config file. |
| 13 | +5. Include the output `{!! Notify::render() !!}` in your master view template. |
| 14 | +6. *Optional*: Modify the configuration file located in config/notify.php. |
| 15 | + |
| 16 | +Usage |
| 17 | +----- |
| 18 | + |
| 19 | +Call one of these methods in your controllers to insert a notification: |
| 20 | + - `Notify::warning($message, $title = null, $options = [])` - add a warning notification |
| 21 | + - `Notify::error($message, $title = null, $options = [])` - add an error notification |
| 22 | + - `Notify::info($message, $title = null, $options = [])` - add an info notification |
| 23 | + - `Notify::success($message, $title = null, $options = [])` - add a success notification |
| 24 | + - `Notify::add($type: warning|error|info|success, $message, $title = null, $options = [])` - add a notification |
| 25 | + - **`Notify::clear()` - clear all current notification** |
| 26 | + |
| 27 | +Configuration |
| 28 | +------------- |
| 29 | + |
| 30 | +Open `config/notify.php` to adjust package configuration. If this file doesn't exist, run `php artisan vendor:publish --provider="Helmesvs\Notify\NotifyServiceProvider" --tag="notify"` to create the default configuration file. |
| 31 | + |
| 32 | + |
| 33 | +### General Options |
| 34 | +``` php |
| 35 | +'options' => [ |
| 36 | + 'lib' => 'toastr', |
| 37 | + 'style' => 'custom' |
| 38 | +] |
| 39 | +``` |
| 40 | + |
| 41 | +Set `'lib'` as `toastr` to use [toastr.js](https://github.com/CodeSeven/toastr) or `pnotify` to use [pnotify.js](https://github.com/sciactive/pnotify). |
| 42 | + |
| 43 | +Set `'style'` to `'custom'` to use custom settings, or as `'default'` to default library settings. |
| 44 | + |
| 45 | +The style of notifications can be customized in `public/vendor/Notify/style.css`. |
| 46 | + |
| 47 | +### Options Toastr |
| 48 | +``` php |
| 49 | +'ToastrOptions' => [ |
| 50 | + "closeButton" => false, |
| 51 | + "closeHtml" => '', |
| 52 | + "newestOnTop" => true, |
| 53 | + "progressBar" => false, |
| 54 | + ... |
| 55 | +] |
| 56 | +``` |
| 57 | + |
| 58 | +### Options PNotify |
| 59 | +``` php |
| 60 | +'PNotifyOptions' => [ |
| 61 | + 'title_escape' => false, |
| 62 | + 'text_escape' => false, |
| 63 | + 'styling' => 'brighttheme', |
| 64 | + 'addclass' => '', |
| 65 | + ... |
| 66 | +] |
| 67 | +``` |
| 68 | + |
| 69 | +For a list of available options, see [toastr.js' documentation](https://github.com/CodeSeven/toastr) and [pnotify.js' documentation](https://github.com/sciactive/pnotify). |
0 commit comments