Download the PHP package dp-websolutions/laravel-flash without Composer
On this page you can find all versions of the php package dp-websolutions/laravel-flash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-flash
Tailwind flash alert messages and validations for your Laravel apps
This composer package offers an easy way to manage and show laravel flash message alert notifications. Works with Tailwindcss (default) and Bootstrap.
It includes default messages for most commonly used actions such as "success", "error" messages, or CRUD operations (stored, updated, deleted).
Multiple messages can be pushed and displayed.
Installation
Install the package:
Theming
The package does not include any css file. Don't forget to include the framework of your choice.
Alert notifications use tailwind by default, but you can use bootstrap if you want. To see how it works, include the value in your .env file.
If you are using tailwind with purgeCss, you may need to publish the views included in the package, so when Laravel compile the views, purgeCss will remove any unused css class.
You can publish and modify the config and view files (seed docs below).
Usage
Inside any place of your app (typically a controller or middleware) call the "flash" helper included with the package:
The package includes most of the common messages for different actions inside most laravel applications:
Once you have flashed a message in session, you will need to display it in your view. Use the component included in the package:
Don't like the new component syntax? It's ok, use the directive included with the package:
JS API
One or multiple messages can be also flashed via a JS API.
Example
Configuration
You can export the config file to change default messages, views and enable some extra features. You can dot it executing:
Now you should have a flash.php
file inside the config folder.
After upgrading laravel-flash to a major version, don't forget to include
--force
at the end of the above command, to force to re-publish the config file.
Customizing views
Views are really easy to use and modify. You can export the included views to adapt to your needs. You may do su executing:
Now you should have views inside resources/views/vendor/flash
folder. If you are upgrading the package, don't forget to include --force
at the end of the above command, to force to re-publish the vies.
Using default validations view
By default, the package show the validation errors inside the flash::messages
view. Validation errors are showed inside an "alert-danger" as an unordered list.
You can disable this behaviour by changing flash.validations.enabled
to false
in config/flash.php
file.
If you wish, you can modify this view to adapt to your needs, executing:
Example
The package doesn't includes Bootstrap or any other styling or frontend assets frameworks, so you need to import the necessary stylesheets.
Tailwind style
Bootstrap styles
Success
Error
Dismissible
Static
Validations
Tips
All alerts dismissible by default
By default, all alerts are dismissible. You can disable this by changing flash.dismissible
to false
.
If you set flash.dismissible
false
, you still can make dismissible a certain alert by chaining:
Or make a certain alert static by calling:
Why another flash package?
There are great packages to create flash messages:
The main difference with each one is the ability to set a default message for most common actions (a success action, a model stored, a model updated, a model deleted..).
I decided to create this package to suit my own needs, as most of the time I end up working with many controllers with the basic CRUD operations (Cread, Read, Update, Delete) and writing a message for each operation does not seem to me to be the best way to handle the same message for each operation.