Skip to content

Commit

Permalink
ADD shortcut to add a notification if particular condition is true if…
Browse files Browse the repository at this point in the history
…Warning($condition,..), ifSuccess($condition,..) etc..
  • Loading branch information
lopadova committed Jul 4, 2024
1 parent b612aa3 commit 412ef76
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 243 deletions.
1 change: 0 additions & 1 deletion .idea/laravel-notifier.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ Call one of these methods in your controllers to insert a notification:
- `Notify::add($type: warning|error|info|success, $message, $title = null, $options = [])` - add a notification
- `Notify::clear()` - clear all current notification

If you need to show the notification only if a particular condition is true, you can use these methods:

- `Notify::ifWarning($condition, $message, $title = null, $options = [])` - add a warning notification if $condition is true
- `Notify::ifError($condition, $message, $title = null, $options = [])` - add an error notification if $condition is true
- `Notify::ifInfo($condition, $message, $title = null, $options = [])` - add an info notification if $condition is true
- `Notify::ifSuccess($condition, $message, $title = null, $options = [])` - add a success notification if $condition is true

Example:
instead of use this:

```php
if($condition){
Notify::success('You have an email!', 'New Email');
}
```

you can use this:

```php
Notify::IfSuccess($condition, 'You have an email!', 'New Email');
```

```php
{!! notify() !!}

```
### EXAMPLE:

Expand Down
Loading

0 comments on commit 412ef76

Please sign in to comment.