Download the PHP package mckenziearts/laravel-notify without Composer
On this page you can find all versions of the php package mckenziearts/laravel-notify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mckenziearts/laravel-notify
More information about mckenziearts/laravel-notify
Files in mckenziearts/laravel-notify
Package laravel-notify
Short Description Flexible flash notifications for Laravel
License MIT
Informations about the package laravel-notify
Introduction
Laravel Notify is a lightweight Laravel package for displaying backend-driven notifications in your application.
Installation
You can install the package using composer
You can publish the configuration file and assets by running:
Option 1: With Tailwind CSS & Alpinejs
If your project already uses Tailwind CSS 4.x, follow these steps to integrate Laravel Notify directly into your build process.
Step 1: Configure Tailwind to scan package files
In your resources/css/app.css, add the package's Blade files to Tailwind's content sources using the @source directive:
Step 2: Import the JavaScript
In your resources/js/app.js, import Alpine.js if you haven't already:
Step 3: Add the notification component to your layout
In your main Blade layout file (e.g., resources/views/layouts/app.blade.php):
Step 4: Build your assets
✅ Done! Tailwind will automatically generate CSS for all the notification styles used in the package.
Option 2: Without Tailwind CSS
If you don't use Tailwind CSS in your project, you can use the pre-compiled CSS and JavaScript files.
Add directives to your layout
✅ Done! The pre-compiled assets will be loaded from your public/vendor/mckenziearts/laravel-notify/dist/ directory.
Usage
Within your controllers, before you perform a redirect call the notify method with a title.
Type of notifications
Laravel Notify actually display 5 types of notifications
-
toastnotification, (The default notification for Laravel Notify) -
connectifynotification, example of basic usage -
drakify(😎) notification, displays an alert only -
smileynotification, displays a simple custom toast notification using the smiley (😊) emoticon emotifynotification, displays a simple custom toast notification using a vector emoticon
Setting a duration
By default, notifications are shown for 5 seconds before they're automatically closed. You may customize this using the duration() method:
If you'd like to make a notification stay open until the user manually closes it, you can set a very long duration:
You can also configure a default duration for all notifications in the config/notify.php file:
Adding Actions to Notifications
You can add interactive actions to your notifications, allowing users to perform tasks directly from the notification. Actions support both navigation (redirecting to a URL) and execution (calling a controller action).
Note: Actions are supported only for the following notification models: Toast, Connect, Smiley, and Emotify. The Drake model does not support actions.
Basic Usage
URL Actions (Navigation)
Use the url() method to redirect users to another page. This creates a simple link (GET request):
You can open URLs in a new tab using the openUrlInNewTab() method:
Action Actions (Execution)
Use the action() method to execute a controller action. This sends an HTTP request (POST by default) to your controller:
You can specify the HTTP method using the method() method:
If you don't specify a method, it defaults to POST.
Complete Example
Custom Styling
You can customize the appearance of action buttons using the classes() method:
Important Notes
- Mutual Exclusivity: You cannot use both
action()andurl()on the same action. Choose one or the other. - Method Restriction: The
method()function can only be used withaction(). Using it withurl()will throw an exception. - New Tab Restriction: The
openUrlInNewTab()function can only be used withurl(). Using it withaction()will throw an exception. - Auto-close: When an action is executed successfully, the notification automatically closes.
- CSRF Protection: Action requests automatically include CSRF tokens and proper headers.
- Supported Models: Actions work with
Toast,Connect,Smiley, andEmotifynotification models only.
Preset Notifications
If you have a specific notification that is used across multiple different places in your system, you can define it as a preset notification in your config file. This makes it easier to maintain commonly used notifications in one place. Read how to define preset messages in the Config section below.
As an example, to use a preset notification you have defined called 'common-notification', use the following:
You can override any of the values that are set in the config if you need to. For example, this could be useful if you have a common notification across, but you want to change the icon in one particular place that it's used without having to manually write out a new notification.
To do this, simply pass in an array that has the key of the attribute that you want to override and the value you want to override it with.
As an example, we could override the 'title' of our 'common-notification' by using the following:
Config
Config file are located at config/notify.php after publishing NotifyServiceProvider.
You can define preset notifications in the config file using the following structure:
The example above shows the config for two preset notifications: 'user-updated' and 'user-deleted'.
Credits
- Arthur Monney
- All Contributors
All versions of laravel-notify with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/session Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
mckenziearts/blade-untitledui-icons Version v1.5.0