Skip to main content
The Panel class is the central configuration object for WireChat. It uses multiple traits to provide a comprehensive API for customizing chat functionality, appearance, and behavior.

Namespace

Wirechat\Wirechat\Panel

Overview

The Panel class orchestrates all WireChat configuration through modular traits, providing methods to configure authentication, broadcasting, colors, layouts, middleware, and more.

Creating a Panel

make()

Create a new Panel instance using the service container.
public static function make(): static
return
static
A new Panel instance resolved from the application container
Example:
$panel = Panel::make()
    ->id('admin-chat')
    ->heading('Admin Chat Panel');

Configuration Methods

default()

Mark this panel as the default panel.
public function default(bool|Closure $condition = true): static
condition
bool|Closure
default:"true"
Whether this panel should be the default. Can be a boolean or a Closure that returns a boolean.
Example:
Panel::make()
    ->default(true);

// Or with a closure
Panel::make()
    ->default(fn() => auth()->user()->isAdmin());

isDefault()

Check if this panel is set as the default.
public function isDefault(): bool
return
bool
Returns true if this panel is the default

register()

Register the panel with WireChat. This method is called internally during panel setup.
public function register(): void

Available Traits

The Panel class uses the following traits to provide comprehensive functionality:

Properties

isDefault
bool|Closure
default:"false"
Determines whether this panel is the default panel. Protected property evaluated through the isDefault() method.

Example Usage

use Wirechat\Wirechat\Panel;

// Create a fully configured panel
$panel = Panel::make()
    ->id('support-chat')
    ->default(true)
    ->heading('Customer Support')
    ->colors([
        'primary' => '#3b82f6',
        'secondary' => '#64748b',
    ]);

// Check if it's the default panel
if ($panel->isDefault()) {
    // Panel-specific logic
}

// Register the panel
$panel->register();

Notes

  • The Panel class is designed to be extended and customized through its various traits
  • All configuration methods typically return $this for method chaining
  • Closures can be used throughout for dynamic configuration based on runtime context
  • The make() method uses Laravel’s service container for dependency injection