Download the PHP package mayankjanidev/alert without Composer
On this page you can find all versions of the php package mayankjanidev/alert. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mayankjanidev/alert
More information about mayankjanidev/alert
Files in mayankjanidev/alert
Package alert
Short Description Create customizable UI alerts in Laravel
License MIT
Informations about the package alert
Alert For Laravel
Create customizable UI alerts in Laravel.
Requirements
- PHP >= 8.1
- Laravel >= 9.0
Installation
Install the package via Composer:
Basic Usage
Show the alert using the blade component:
Customize the alert message:
Add a title to your alerts (optional):
Config
Though completely optional, you can publish the config file to customize the below settings:
session_key
is used to set alert message in the session. Default isalert
.theme
is used to set the styling for alert message. Default isdefault
.
Styling
This package does not depend on any external css or js and should work out of the box without any setup. However, you can customize the default design by publishing the views.
TailwindCSS
If you already have TailwindCSS installed, this package provides Tailwind specific design.
Update the config to switch to Tailwind.
Also add the path to the tailwind config so it does not purge the classes when building the app.css file.
You can also customize Tailwind design by publishing its views:
Alert Types
Currently, 4 types are supported: info, success, warning and failure. Use them like:
Custom Alert Types
Use the custom()
method to create your own alert types.
Make sure to create the appropriate view file at resources.views.vendor.alert.components.danger
Model Alerts
Managing alerts for model specific events like created, updated and deleted throughout your app can feel repetitive.
Use the model()
method to automatically manage that.
This will output "Post was updated.".
Similar messages will be shown for the created and deleted events. It will automatically detect the state of your model.
Customize text for model alerts
Publish the lang file and customize it to your liking.
You can also override text for specific models:
Title is also supported for alert models:
Custom actions for model alerts
If you performed a custom action on a model other than create, update or delete, then you can specify it using the action()
method.
Custom lang parameters
Lang parameters are autofilled if the model has the attribute with the same name.
You can still manually specify lang parameters using the lang()
method.
Custom Entity Alerts
If you want the same features of a model alert on a custom entity, use the for()
method.
All the model alert features like lang files, custom actions and lang parameters behave the same way for custom entity alerts.
Meta Data
You can add additional meta data to an alert. Good use cases could be links.
JS Frameworks
Though this package does not supply any js components for frameworks like vue or react, you can still use the alert data to build your own component.
Use the json()
method to get the current alert data in a json object.
License
This package is released under the MIT License.
All versions of alert with dependencies
illuminate/session Version ^9.0 || ^10.0 || ^11.0
illuminate/support Version ^9.0 || ^10.0 || ^11.0