Toast facade is a Laravel facade that provides static access to the Toaster class. It offers a simple and clean API for creating toast notifications.
Quick start
Methods
success()
Create a success toast notification.The message to display in the toast notification.
An optional title for the toast notification.
Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
Toaster instance for method chaining
Example:
error()
Create an error toast notification.The error message to display in the toast notification.
An optional title for the toast notification.
Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
Toaster instance for method chaining
Example:
info()
Create an informational toast notification.The informational message to display.
An optional title for the toast notification.
Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
Toaster instance for method chaining
Example:
warning()
Create a warning toast notification.The warning message to display.
An optional title for the toast notification.
Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
Toaster instance for method chaining
Example:
add()
Create a toast notification with a specific level.The message to display in the toast notification.
The level/type of the toast. Can be
ToastLevel::Success, ToastLevel::Error, ToastLevel::Info, or ToastLevel::Warning.An optional title for the toast notification.
Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
Toaster instance for method chaining
Example:
Method chaining
All methods return theToaster instance, allowing you to chain multiple toast notifications:
Additional methods
hasPending()
Check if there are pending toasts that have been added.bool - true if there are pending toasts, false otherwise
Example:
getPropKey()
Get the Inertia prop key used for toast notifications.string - The prop key (default: 'toasts')
Example:
The Toast facade is bound to the
Toaster class in the Laravel service container. All method calls are forwarded to the Toaster instance.