Skip to main content

Overview

The Wirechat facade provides convenient access to WireChat’s core services, panel registry, and configuration values. It’s the primary interface for programmatically interacting with WireChat’s global state.
use Wirechat\Wirechat\Facades\Wirechat;

Panel Management

getPanel

Get a specific panel by ID or provider class, with fallback to the default panel.
public function getPanel(?string $idOrClass = null): ?Panel
Parameters:
idOrClass
string|null
Panel ID (e.g., ‘admin’) or fully qualified provider class name
Returns: Panel|null - The requested panel or null if not found Examples:
// Get default panel
$panel = Wirechat::getPanel();

// Get specific panel by ID
$adminPanel = Wirechat::getPanel('admin');

// Get panel by provider class
$panel = Wirechat::getPanel(ChatsPanelProvider::class);

currentPanel

Get the currently active panel based on the request context.
public function currentPanel(): ?Panel
Returns: Panel|null - The current panel or null if none is active Example:
$current = Wirechat::currentPanel();
$colors = $current?->getColors();

getDefaultPanel

Get the panel marked as default.
public function getDefaultPanel(): ?Panel
Returns: Panel|null - The default panel Throws: NoPanelProvidedException if no default panel is registered Example:
try {
    $default = Wirechat::getDefaultPanel();
} catch (NoPanelProvidedException $e) {
    // Handle case where no default panel exists
}

panels

Get all registered panels.
public function panels(): ?array
Returns: array|null - Array of all registered Panel instances Example:
$allPanels = Wirechat::panels();
foreach ($allPanels as $panel) {
    echo $panel->getId() . ': ' . $panel->getPath();
}

Storage Access

storage

Get the storage service for managing attachments and file operations.
public function storage(): StorageService
Returns: StorageService instance Example:
$storage = Wirechat::storage();
$disk = $storage->disk();
$directory = $storage->attachmentsDirectory();

Configuration Helpers

tablePrefix

Get the database table prefix from configuration.
public static function tablePrefix(): ?string
Returns: string|null - Table prefix or null if not set Example:
$prefix = Wirechat::tablePrefix(); // 'wirechat_'

formatTableName

Format a table name with the configured prefix.
public static function formatTableName(string $table): string
Parameters:
table
string
required
Base table name without prefix
Returns: string - Prefixed table name Example:
$fullName = Wirechat::formatTableName('messages');
// Returns: 'wirechat_messages'

usesUuidForConversations

Check if the application is configured to use UUIDs for conversation IDs.
public static function usesUuidForConversations(): bool
Returns: bool - True if UUIDs are enabled for conversations Example:
if (Wirechat::usesUuidForConversations()) {
    // Handle UUID-based conversation IDs
}

UI Configuration

maxGroupMembers

Get the maximum number of members allowed per group.
public static function maxGroupMembers(): int
Returns: int - Maximum group size (default: 1000) Example:
$limit = Wirechat::maxGroupMembers();
if ($group->participants()->count() >= $limit) {
    throw new Exception("Group is full");
}

Route Names

indexRouteName

Get the route name for the conversations list page.
public static function indexRouteName(): string
Returns: string - Route name (‘chats’) Example:
return redirect()->route(Wirechat::indexRouteName());

viewRouteName

Get the route name for the individual chat view page.
public static function viewRouteName(): string
Returns: string - Route name (‘chat’) Example:
return redirect()->route(Wirechat::viewRouteName(), $conversationId);

Broadcasting & Queue Configuration

messagesQueue

Get the queue name for message broadcasting.
public static function messagesQueue(): string
Returns: string - Queue name (default: ‘default’) Example:
BroadcastMessage::dispatch($message)->onQueue(Wirechat::messagesQueue());

notificationsQueue

Get the queue name for notification broadcasting.
public static function notificationsQueue(): string
Returns: string - Queue name (default: ‘default’) Example:
NotifyParticipants::dispatch($notification)->onQueue(Wirechat::notificationsQueue());

Deprecated Methods

The following methods are deprecated and will be removed in future versions. Use the StorageService methods instead.

storageFolder (deprecated)

public static function storageFolder(): string
Use instead: Wirechat::storage()->attachmentsDirectory()

diskVisibility (deprecated)

public static function diskVisibility(): string
Use instead: Wirechat::storage()->visibility()

storageDisk (deprecated)

public static function storageDisk(): string
Use instead: Wirechat::storage()->disk()

Usage Examples

Check Panel Capabilities

use Wirechat\Wirechat\Facades\Wirechat;

$panel = Wirechat::currentPanel();

if ($panel && $panel->hasGroups()) {
    // Show create group button
}

Dynamic Route Generation

use Wirechat\Wirechat\Facades\Wirechat;

// Redirect to chat list
return redirect()->route(
    Wirechat::currentPanel()->getId() . '.' . Wirechat::indexRouteName()
);

Storage Operations

use Wirechat\Wirechat\Facades\Wirechat;

$storage = Wirechat::storage();

// Save attachment
$path = $storage->putFile($file, 'attachments');

// Get public URL
$url = Storage::disk($storage->disk())->url($path);

Source Reference

  • Facade: ~/workspace/source/src/Facades/Wirechat.php
  • Service: ~/workspace/source/src/Services/WirechatService.php
  • Storage Service: ~/workspace/source/src/Services/StorageService.php