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.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.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.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.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 level/type of the toast. Can be
ToastLevel::Success, ToastLevel::Error, ToastLevel::Info, or ToastLevel::Warning.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.