Skip to main content

Overview

Panels in WireChat are configured using a fluent API through the Panel class. Each configuration method returns the panel instance, allowing you to chain multiple configurations.

Basic Configuration

Identity & Routing

id
string
required
Unique identifier for the panel. Must be set before registration.
$panel->id('admin')
The panel ID cannot be changed after initial registration.
path
string
required
Base URL path for the panel’s routes.
$panel->path('admin') // Accessible at /admin
default
bool|Closure
default:"false"
Marks this panel as the default panel.
$panel->default()
$panel->default(fn() => config('app.env') === 'production')

Authentication

guards
array|Closure
default:"['web']"
Authentication guards used to authenticate users.
$panel->guards(['web'])
$panel->guards(['web', 'admin'])
middleware
array
default:"['auth']"
Middleware applied to all panel routes. New middleware is merged with existing.
$panel->middleware(['auth', 'verified'])

Layout & Views

layout
string|Closure|null
default:"'wirechat::layouts.app'"
Custom layout view for the panel.
$panel->layout('layouts.chat')
$panel->layout(fn() => auth()->user()->isAdmin() ? 'layouts.admin' : 'layouts.app')
homeUrl
string|Closure|null
Home URL for navigation purposes.
$panel->homeUrl('/dashboard')
$panel->homeUrl(fn() => route('dashboard'))

Route Configuration

registerRoutes
bool|Closure
default:"true"
Enable or disable automatic route registration.
$panel->registerRoutes(false)
routes
Closure
Register custom routes for the panel.
$panel->routes(function ($panel) {
    Route::get('/settings', [SettingsController::class, 'index']);
    Route::post('/settings', [SettingsController::class, 'update']);
})

SPA Mode

spa
bool|Closure
default:"false"
Enable Single Page Application mode for smoother navigation without full page reloads.
$panel->spa()
$panel->spa(true)
$panel->spa(fn() => config('app.env') === 'production')
When enabled, Livewire’s SPA mode provides instant navigation between chat pages with client-side routing.
spaUrlExceptions
array|Closure
default:"[]"
URLs that should bypass SPA mode and perform full page loads.
$panel->spaUrlExceptions(['/chat/settings', '/chat/admin'])
$panel->spaUrlExceptions(fn() => [route('chat.export')])
Useful for pages that require server-side rendering or external navigation.

Attachments

Configure file and media attachment handling:
attachments
bool|Closure
default:"false"
Enable all attachments (both files and media).
$panel->attachments()
fileAttachments
bool|Closure
default:"false"
Enable file attachments specifically.
$panel->fileAttachments()
mediaAttachments
bool|Closure
default:"false"
Enable media attachments (images, videos).
$panel->mediaAttachments()
maxUploads
int|Closure
default:"10"
Maximum number of files that can be uploaded at once.
$panel->maxUploads(5)
mediaMimes
array|Closure
default:"['png', 'jpg', 'jpeg', 'gif', 'mov', 'mp4']"
Allowed MIME types for media uploads.
$panel->mediaMimes(['png', 'jpg', 'jpeg', 'webp'])
mediaMaxUploadSize
int|Closure
default:"12288"
Maximum upload size for media files in kilobytes (default: 12MB).
$panel->mediaMaxUploadSize(20480) // 20MB
fileMimes
array|Closure
default:"['zip', 'rar', 'txt', 'pdf']"
Allowed MIME types for file uploads.
$panel->fileMimes(['pdf', 'doc', 'docx', 'xls', 'xlsx'])
fileMaxUploadSize
int|Closure
default:"12288"
Maximum upload size for files in kilobytes (default: 12MB).
$panel->fileMaxUploadSize(10240) // 10MB

Attachment Example

return $panel
    ->id('admin')
    ->path('admin')
    ->attachments() // Enable all attachments
    ->maxUploads(15)
    ->mediaMimes(['png', 'jpg', 'jpeg', 'gif', 'webp'])
    ->mediaMaxUploadSize(20480) // 20MB
    ->fileMimes(['pdf', 'doc', 'docx', 'zip'])
    ->fileMaxUploadSize(10240); // 10MB

Broadcasting

Configure real-time broadcasting for the panel:
broadcasting
bool|Closure
default:"true"
Enable or disable broadcasting for the panel.
$panel->broadcasting()
$panel->broadcasting(false)
messagesQueue
string|Closure
default:"'messages'"
Queue name for message broadcasts.
$panel->messagesQueue('high-priority')
eventsQueue
string|Closure
default:"'default'"
Queue name for event broadcasts.
$panel->eventsQueue('events')

Colors

Customize the panel’s color scheme:
colors
array|Closure
Register custom colors for the panel. Colors must include all shade values from 50 to 950.
use Wirechat\Wirechat\Support\Color;

$panel->colors([
    'primary' => Color::Blue,
    'secondary' => Color::Slate,
])
See Colors Configuration for more details.

Notifications

Configure web push notifications:
webPushNotifications
bool|Closure
default:"false"
Enable web push notifications.
$panel->webPushNotifications()
serviceWorkerPath
string|Closure
default:"asset('sw.js')"
Path to the service worker file.
$panel->serviceWorkerPath(asset('custom-sw.js'))

Complete Example

Here’s a comprehensive panel configuration:
namespace App\Providers\Wirechat;

use Wirechat\Wirechat\Panel;
use Wirechat\Wirechat\PanelProvider;
use Wirechat\Wirechat\Support\Color;

class AdminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // Identity & Routing
            ->id('admin')
            ->path('admin')
            ->default()
            
            // Authentication
            ->guards(['web'])
            ->middleware(['auth', 'verified'])
            
            // Layout
            ->layout('layouts.admin')
            ->homeUrl('/dashboard')
            
            // Attachments
            ->attachments()
            ->maxUploads(10)
            ->mediaMimes(['png', 'jpg', 'jpeg', 'gif', 'webp'])
            ->mediaMaxUploadSize(20480) // 20MB
            ->fileMimes(['pdf', 'doc', 'docx', 'zip'])
            ->fileMaxUploadSize(10240) // 10MB
            
            // Broadcasting
            ->broadcasting()
            ->messagesQueue('messages')
            ->eventsQueue('default')
            
            // Colors
            ->colors([
                'primary' => Color::Blue,
                'secondary' => Color::Slate,
            ])
            
            // Notifications
            ->webPushNotifications()
            ->serviceWorkerPath(asset('sw.js'))
            
            // Custom Routes
            ->routes(function ($panel) {
                Route::get('/analytics', [AnalyticsController::class, 'index'])
                    ->name('analytics');
            });
    }
}

Accessing Panel Configuration

You can access panel configuration at runtime:
use Wirechat\Wirechat\Facades\Wirechat;

$panel = Wirechat::getPanel('admin');

// Check configuration
$hasBroadcasting = $panel->hasBroadcasting();
$hasAttachments = $panel->hasAttachments();
$guards = $panel->getGuards();
$middleware = $panel->getMiddleware();

// Get URLs
$chatsUrl = $panel->chatsRoute();
$chatUrl = $panel->chatRoute($conversationId);

Dynamic Configuration

Many configuration methods accept closures for dynamic values:
return $panel
    ->id('admin')
    ->path('admin')
    ->guards(fn() => auth()->user()?->isAdmin() ? ['admin'] : ['web'])
    ->layout(fn() => auth()->user()?->theme === 'dark' ? 'layouts.dark' : 'layouts.light')
    ->broadcasting(fn() => config('broadcasting.enabled'))
    ->maxUploads(fn() => auth()->user()?->isPremium() ? 50 : 10);
Closures are evaluated when the configuration value is accessed, allowing for context-aware configuration.