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;
}
use Illuminate\Database\Eloquent\Builder;
FilamentTeamChatPlugin::make()
->modifyAvailableUsersQueryUsing(function (Builder $query, User $user): Builder {
if ($user->is_admin) {
return $query; // Admins can chat with everyone
}
// Others can chat with admins and members of their own teams
return $query->where(fn (Builder $query) => $query
->where('is_admin', true)
->orWhereHas('teams', fn (Builder $query) => $query->whereKey($user->teams->modelKeys())));
})