PHP code example of qalainau / filament-team-chat
1. Go to this page and download the library: Download qalainau/filament-team-chat library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qalainau / filament-team-chat example snippets
use Filament\TeamChat\FilamentTeamChatPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(FilamentTeamChatPlugin::make());
}
use Filament\TeamChat\Concerns\HasTeamChat;
class User extends Authenticatable
{
use HasTeamChat;
}
// config/team-chat.php
return [
'table_prefix' => 'tc_',
'user_model' => \App\Models\User::class,
'polling' => [
'messages' => 3, // seconds
'sidebar' => 5, // seconds
],
'uploads' => [
'disk' => 'public',
'directory' => 'team-chat-attachments',
'max_size' => 10240, // KB
],
'tenancy' => [
'enabled' => false,
'model' => null, // e.g. \App\Models\Team::class
'resolver' => null, // null = Filament::getTenant()
],
];
use Filament\TeamChat\Models\Channel;
// Create a channel
$channel = Channel::create([
'name' => 'general',
'slug' => 'general',
'type' => 'public', // or 'private'
'created_by' => $user->id,
]);
$channel->members()->attach($user->id, ['role' => 'owner']);
// DMs (idempotent — returns existing conversation if found)
$dm = $user->findOrCreateDirectMessage($otherUser->id);
// Group DM
$group = $user->createGroupConversation(
userIds: [$user2->id, $user3->id],
name: 'Project Team',
);
use Filament\TeamChat\Actions\SendMessage;
$message = app(SendMessage::class)->execute(
messageable: $channel, // Channel or Conversation
userId: $user->id,
body: 'Hello @Jordan! Check this **bold** text.',
parentId: null, // set for thread replies
files: [], // array of UploadedFile
);
use Filament\TeamChat\Actions\{ToggleReaction, MarkAsRead, SearchMessages};
// Toggle reaction (returns true=added, false=removed)
app(ToggleReaction::class)->execute($message->id, $user->id, '👍');
// Unread count
$channel->unreadCountFor($user->id); // => 3
// Mark as read
app(MarkAsRead::class)->execute($channel, $user->id);
// Search (respects channel/DM membership)
$results = app(SearchMessages::class)->execute($user->id, 'deploy', limit: 20);
bash
php artisan vendor:publish --tag=team-chat-migrations
php artisan migrate
bash
php artisan make:notifications-table
php artisan migrate
bash
php artisan filament:theme
bash
php artisan vendor:publish --tag=team-chat-config