Download the PHP package zaichaopan/flash without Composer
On this page you can find all versions of the php package zaichaopan/flash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zaichaopan/flash
More information about zaichaopan/flash
Files in zaichaopan/flash
Package flash
Short Description A simple package to make flash message more flexible
License MIT
Informations about the package flash
Flash
This package makes Laravel flash message more flexible. It can be used in laravel 5.5 or higher.
Installation
Usage
In laravel, you can flash message like below
Or you can use the with method when redirect
But the problem is when it comes to showing flash message in blade, your flash message may have different keys (e.g. error, success, ...). You have to check all the possible keys to determine if you have flash message to show in the blade. This package can be used to make things easier.
- To flash a message
This packages provides a global helper method flash to create a Flash instance. After you create the Flash instance, there are five available methods you can call to generate five different types of flash messages. Each method takes two parameters: message and options.
The first one is required which is used to set the message body of the flash. The second one is an array and it is optional. It is used to add addition data to the flash.
-
Check whether flash exists:
-
Get flash type:
-
Get flash message
-
Get additional option data
- Pass data to javascript
In real life, you may want to create a flash component in vue, which can be used to display the flash message from the server or from the js. To do that, let's say you have a component called Flash.vue and there is a property called flash inside it.
Now if there is no flash, the value of the flash property will be null. If there is a flash message, the value will be an object contains properties: message, type, options.