Chats
Wirechat allows you to create private 1-on-1 chats, manage settings from the panel, send messages, and perform actions such as deleting or clearing chats.
#Creating Chats
To allow users to create new chats, enable the action in your Wirechat panel:
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//...
->createChatAction();
}
Note: If disabled, users won’t see the option to create new chats in the UI.
-
Create Using the WireChat UI
- Click the Plus icon in the chat list.
- Search for and select a user to start a conversation with. Customize Search.
- Click on the user’s name to initiate a chat.
-
Creating a Private Chat Programmatically
With another user:
$otherUser = User::first();
$auth = auth()->user();
$conversation = $auth->createConversationWith($otherUser, 'Optional message');
With yourself:
$auth = auth()->user();
$conversation = $auth->createConversationWith($auth, 'Optional message');
Note: If a conversation already exists between the two participants, it will be returned instead of creating a new one.
#Deleting Chats
Deleting a chat removes it from your list and clears its messages. In private chats, it stays deleted unless a new message is sent or received.
#Enable Delete Action
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//...
->deleteChatAction();
}
#How to Delete
-
UI Instructions
- Open a chat.
- Choose Delete Chat from the menu or Chat Info.
-
Programmatically
$auth = auth()->user(); $conversation = $auth->conversations()->first(); $conversation->deleteFor($auth);
Note: When you delete a chat, other participants still keep their copy. A conversation is permanently removed only if all participants delete it or if it’s a self-chat.
#Clearing Chats
Clearing removes all messages for you but keeps the conversation visible for other participants.
#Enable Clear Action
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//...
->clearChatAction();
}
#How to Clear
-
UI Instructions
- Open a chat.
- Select Clear Chat History from the menu or Chat Info.
-
Programmatically
$auth = auth()->user(); $conversation = $auth->conversations()->first(); $conversation->clearFor($auth);