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
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
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
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:
Provides the ability to evaluate closures for dynamic configuration values.
Configures custom actions available in the chat interface.
Controls file attachment functionality and settings.
Manages authentication configuration for the chat panel.
Configures real-time broadcasting settings for live updates.
Defines actions available within individual chats.
Registers middleware for chat operations.
Configures search functionality for conversations.
Customizes the color scheme of the chat interface.
Show HasDeleteMessageActions
Controls message deletion behavior and permissions.
Enables and configures the emoji picker component.
Sets custom favicon for the chat panel.
Defines actions available for group management.
Configures group chat functionality.
Sets the heading/title for the chat panel.
Enables the heart/like reaction feature.
Assigns a unique identifier to the panel.
Configures the layout and appearance of the chat interface.
Registers global middleware for the panel.
Defines custom routes for the chat panel.
Show HasSearchableAttributes
Configures which attributes are searchable in the chat.
Configures user search functionality.
Show HasWebPushNotifications
Enables and configures web push notifications.
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