> ## Documentation Index
> Fetch the complete documentation index at: https://veekthoven-laravel-inertia-toast-24-61.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Toast facade

> The Toast facade provides a convenient static interface for creating toast notifications in Laravel

The `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

```php theme={null}
use InertiaToast\Facades\Toast;

Toast::success('User created successfully');
Toast::error('An error occurred');
Toast::info('This is an informational message');
Toast::warning('Please be careful');
```

## Methods

### success()

Create a success toast notification.

```php theme={null}
Toast::success(string $message, ?string $title = null, ?int $duration = null): Toaster
```

<ParamField path="message" type="string" required>
  The message to display in the toast notification.
</ParamField>

<ParamField path="title" type="string | null" default="null">
  An optional title for the toast notification.
</ParamField>

<ParamField path="duration" type="int | null" default="null">
  Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
</ParamField>

**Returns:** `Toaster` instance for method chaining

**Example:**

```php theme={null}
Toast::success('User created successfully');
Toast::success('Profile updated', 'Success');
Toast::success('File uploaded', 'Upload Complete', 5000);
```

### error()

Create an error toast notification.

```php theme={null}
Toast::error(string $message, ?string $title = null, ?int $duration = null): Toaster
```

<ParamField path="message" type="string" required>
  The error message to display in the toast notification.
</ParamField>

<ParamField path="title" type="string | null" default="null">
  An optional title for the toast notification.
</ParamField>

<ParamField path="duration" type="int | null" default="null">
  Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
</ParamField>

**Returns:** `Toaster` instance for method chaining

**Example:**

```php theme={null}
Toast::error('Failed to save user');
Toast::error('Validation failed', 'Error');
Toast::error('Connection timeout', 'Network Error', 7000);
```

### info()

Create an informational toast notification.

```php theme={null}
Toast::info(string $message, ?string $title = null, ?int $duration = null): Toaster
```

<ParamField path="message" type="string" required>
  The informational message to display.
</ParamField>

<ParamField path="title" type="string | null" default="null">
  An optional title for the toast notification.
</ParamField>

<ParamField path="duration" type="int | null" default="null">
  Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
</ParamField>

**Returns:** `Toaster` instance for method chaining

**Example:**

```php theme={null}
Toast::info('Please check your email');
Toast::info('New features available', 'Information');
Toast::info('Your session will expire soon', 'Notice', 10000);
```

### warning()

Create a warning toast notification.

```php theme={null}
Toast::warning(string $message, ?string $title = null, ?int $duration = null): Toaster
```

<ParamField path="message" type="string" required>
  The warning message to display.
</ParamField>

<ParamField path="title" type="string | null" default="null">
  An optional title for the toast notification.
</ParamField>

<ParamField path="duration" type="int | null" default="null">
  Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
</ParamField>

**Returns:** `Toaster` instance for method chaining

**Example:**

```php theme={null}
Toast::warning('This action cannot be undone');
Toast::warning('Low disk space', 'Warning');
Toast::warning('Unsaved changes will be lost', 'Caution', 6000);
```

### add()

Create a toast notification with a specific level.

```php theme={null}
Toast::add(
    string $message,
    ToastLevel $level = ToastLevel::Info,
    ?string $title = null,
    ?int $duration = null
): Toaster
```

<ParamField path="message" type="string" required>
  The message to display in the toast notification.
</ParamField>

<ParamField path="level" type="ToastLevel" default="ToastLevel::Info">
  The level/type of the toast. Can be `ToastLevel::Success`, `ToastLevel::Error`, `ToastLevel::Info`, or `ToastLevel::Warning`.
</ParamField>

<ParamField path="title" type="string | null" default="null">
  An optional title for the toast notification.
</ParamField>

<ParamField path="duration" type="int | null" default="null">
  Duration in milliseconds to display the toast. If not provided, uses the default from configuration.
</ParamField>

**Returns:** `Toaster` instance for method chaining

**Example:**

```php theme={null}
use InertiaToast\Enums\ToastLevel;

Toast::add('Custom message', ToastLevel::Success);
Toast::add('Something happened', ToastLevel::Warning, 'Alert');
Toast::add('Processing complete', ToastLevel::Info, 'Status', 4000);
```

## Method chaining

All methods return the `Toaster` instance, allowing you to chain multiple toast notifications:

```php theme={null}
Toast::success('User created')
    ->info('Welcome email sent')
    ->warning('Please verify your email');
```

## Additional methods

### hasPending()

Check if there are pending toasts that have been added.

```php theme={null}
Toast::hasPending(): bool
```

**Returns:** `bool` - `true` if there are pending toasts, `false` otherwise

**Example:**

```php theme={null}
if (Toast::hasPending()) {
    // Toasts have been added
}
```

### getPropKey()

Get the Inertia prop key used for toast notifications.

```php theme={null}
Toast::getPropKey(): string
```

**Returns:** `string` - The prop key (default: `'toasts'`)

**Example:**

```php theme={null}
$key = Toast::getPropKey(); // 'toasts'
```

<Note>
  The Toast facade is bound to the `Toaster` class in the Laravel service container. All method calls are forwarded to the `Toaster` instance.
</Note>
