tsfcorp / uifeedback
Display messages
Installs: 2 664
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.0|^8.0
- illuminate/session: ^5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- orchestra/testbench: 6.*
- phpunit/phpunit: ^5.7|6.2|^8.0|9.*|10.*
README
Makes it easy to give a visual feedback to user
Installation
Require this package in your composer.json
. Run the following command:
composer require tsfcorp/uifeedback
After updating composer, the service provider will automatically be registered and enabled, along with the facade, using Auto-Discovery
Next step is to run the artisan command to bring the config into your project
php artisan vendor:publish --provider="TsfCorp\UiFeedback\UiFeedbackServiceProvider" --tag=config
Update config/uifeedback.php
Usage Instructions
This library is build to work by default with Bootstrap 4.
You can add new messages wherever you'd like in you application, like this:
UiFeedback::set(MessageFormat::SUCCESS, 'message');
set
method has 3 parameters:
- message format: a string represeinting the class that will be added to the HTML container
- message: a string represeinting the class that will be added to the HTML container
- close button (optional, default: true): whether to display or not the close button for the alert
Message format has the following options, but you can specify there whatever class you'd like and customise the CSS in your app.
Convenience methods
You can set a message using the following pattern for supported message formats:
UiFeedback::success('success message'); UiFeedback::danger('error message');
Display messages
In order to display the messages, you can add the following line in your views:
{!! \TsfCorp\UiFeedback\Facades\UiFeedback::get() !!}
Output messages
If you'd like to display a formatted message right away, you can use the following in your views:
{!! \TsfCorp\UiFeedback\Facades\UiFeedback::format(\TsfCorp\UiFeedback\MessageFormat::SUCCESS, 'message'); !!}
Group messages
If you set multiple messages of the same type (for example SUCCESS), a new alert will be generated for each message.
You can change this behaviour by setting the group_errors
to true
. This way messages of the same type will be displayed in the same alert box.
Session errors
UiFeedback can capture validation errors and display these along with other messages you set. This is the default behaviour.
It can be changed in the config: capture_validation_errors
Change output format
In order to change the format for a message you need to publish the view used:
php artisan vendor:publish --provider="TsfCorp\UiFeedback\UiFeedbackServiceProvider" --tag=views
Then you can edit the published view in: resources/views/vendor