Skip to content

Commit 3ddb917

Browse files
committed
Changes for v1.4
1 parent 61007e4 commit 3ddb917

File tree

4 files changed

+59
-22
lines changed

4 files changed

+59
-22
lines changed

CHANGELOG

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
Version 1.4.x -
2+
----------------------------
3+
- New: added possibility to define "dark" message
4+
- Eng: possibility to use short syntax
5+
- Fix: wrong rendering on "error" message
6+
7+
18
Version 1.3.1 - Dec 17, 2020
29
----------------------------
3-
Fix: error in drawing important messages
10+
- Fix: error in drawing important messages
411

512

613
Version 1.3.0 - Dec 17, 2020

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,43 @@ public function store()
4949
}
5050
```
5151

52-
You may also define following flash messages:
53-
54-
| method | description |
55-
|-------------------------------------------|-------------------------------------------------------------------------------|
56-
| `flash('your-message', 'primary')` | Set the flash type to "primary". |
57-
| `flash('your-message', 'secondary')` | Set the flash type to "secondary". |
58-
| `flash('your-message', 'success')` | Set the flash type to "success". |
59-
| `flash('your-message', 'warning')` | Set the flash type to "warning". |
60-
| `flash('your-message', 'danger')` | Set the flash type to "error". |
61-
| `flash('your-message', 'error')` | Set the flash type to "error" (alias to "danger") without a close button. |
62-
| `flash('your-message', 'error', true)` | Set the flash type to "error" with a close button to the flash message. |
63-
| `flash('your-message', 'light')` | Set the flash type to "light". |
64-
65-
You may also use facade directly:
52+
The general way to define a flash message is a following:
53+
```php
54+
flash()->danger('The error message')->important();
55+
flash()->info('The info message');
56+
```
57+
58+
But you may use a shorter syntax:
59+
```php
60+
flash('The error message', true);
61+
flash('The info message');
62+
```
63+
64+
You may also define the following flash messages:
65+
66+
| method | description |
67+
|-------------------------------------------|---------------------------------------------------------------------------|
68+
| `flash('your-message', 'primary')` | Set the flash type to "primary". |
69+
| `flash('your-message', 'secondary')` | Set the flash type to "secondary". |
70+
| `flash('your-message', 'success')` | Set the flash type to "success". |
71+
| `flash('your-message', 'warning')` | Set the flash type to "warning". |
72+
| `flash('your-message', 'info')` | Set the flash type to "info". |
73+
| `flash('your-message', 'danger')` | Set the flash type to "error". |
74+
| `flash('your-message', 'error')` | Set the flash type to "error" (alias to "danger") w/o a close button. |
75+
| `flash('your-message', 'error', true)` | Set the flash type to "error" with a close button to the message. |
76+
| `flash('your-message', 'light')` | Set the flash type to "light". |
77+
| `flash('your-message', 'dark')` | Set the flash type to "dark". |
78+
79+
You may also define messages, by using Flash facade:
6680
```php
6781
use Apphp\Flash\Flash;
6882
```
6983

70-
| method | description |
71-
|-------------------------------------------|-------------------------------------------------------------------------------|
72-
| `Flash::success('your-message')` | Set the success flash message. |
73-
| `Flash::error('your-message')` | Set the flash type to "error" without a close button to the flash message. |
74-
| `Flash::error('your-message', true)` | Set the flash type to "error" with a close button to the flash message. |
84+
| method | description |
85+
|-------------------------------------------|----------------------------------------------------------------------------|
86+
| `Flash::success('your-message')` | Set the success flash message. |
87+
| `Flash::error('your-message')` | Set the flash type to "error" w/o a close button to the message. |
88+
| `Flash::error('your-message', true)` | Set the flash type to "error" with a close button to the message. |
7589
etc.
7690

7791

@@ -158,7 +172,7 @@ div.alert:not(.alert-important) {
158172
```
159173

160174

161-
## Customization
175+
## Customize Views
162176

163177
To change HTML template of the message or use your own, publish view file and customize it according to suit your needs.
164178
```php

src/Apphp/Flash/FlashNotifier.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function error($message = null, $important = false)
8484
}
8585

8686
/**
87-
* Return an error message
87+
* Return a danger message
8888
* Alias to error()
8989
*
9090
* @param string|null $message
@@ -132,6 +132,18 @@ public function light($message = null, $important = false)
132132
return $this->message($message, 'light', $important);
133133
}
134134

135+
/**
136+
* Return a simple dark message
137+
*
138+
* @param string|null $message
139+
* @param bool $important
140+
* @return $this
141+
*/
142+
public function dark($message = null, $important = false)
143+
{
144+
return $this->message($message, 'light', $important);
145+
}
146+
135147
/**
136148
* Save a message
137149
*

src/Apphp/Flash/functions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ function flash($message = null, $level = 'info', $important = false)
1313
{
1414
$notifier = app('flash');
1515

16+
if ($level === 'error') {
17+
$level = 'danger';
18+
}
19+
1620
if ( ! is_null($message)) {
1721
return $notifier->message($message, $level, $important);
1822
}

0 commit comments

Comments
 (0)