1. Go to this page and download the library: Download codenzia/filament-comments 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/ */
codenzia / filament-comments example snippets
use Codenzia\FilamentComments\FilamentCommentsPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentCommentsPlugin::make(),
]);
}
// config/filament-comments.php
'tenancy' => [
'enabled' => true,
'tenant_column' => 'company_id', // the tenant foreign key on the comment tables
'tenant_resolver' => null, // null = use the current Filament panel tenant
],
'tenant_resolver' => \App\Tenancy\CurrentTenantResolver::class, // public function __invoke(): ?int
// or a closure (note: not config:cache-safe)
'tenant_resolver' => fn () => app(\App\Tenancy\CurrentTeam::class)->id(),
use Codenzia\FilamentComments\Traits\HasComments;
class Post extends Model
{
use HasComments;
}
$post->comment('Great article!');
$post->commentAsUser($user, 'Thanks for sharing.');
use Codenzia\FilamentComments\Models\CommentChannel;
// 1-on-1 DM (legacy two-argument syntax still works)
$dm = CommentChannel::findOrCreateDirectMessage($userId1, $userId2);
// Group DM — pass an array of user IDs
$dm = CommentChannel::findOrCreateDirectMessage([$userId1, $userId2, $userId3]);
// config/filament-comments.php
'sidebar_limit' => [
'channels' => 5, // show 5 most recent channels
'direct_messages' => 5, // show 5 most recent DMs
],
use Codenzia\FilamentComments\Commands\InstallCommand;
InstallCommand::seedPermissions();
// Example: grant channel management to a "moderator" role
$role = Role::findByName('moderator');
$role->givePermissionTo([
'create_comment_channel',
'update_comment_channel',
'delete_comment_channel',
'view_comment_channel',
]);
use Codenzia\FilamentComments\Filament\Pages\ManageChannelsPage;
if (ManageChannelsPage::can('create_channel')) {
// user has the create_comment_channel permission
}
// config/filament-comments.php
'composer' => [
'bg' => '#ffffff', // light mode
'dark_bg' => '#16181C', // dark mode
'show_settings' => false, // show a settings cog with color picker
'types' => [...], // which types the + menu offers — see Comment Types
],
// Programmatic usage
$comment->resolve(); // resolves as current user
$comment->resolve($userId); // resolves as specific user
$comment->unresolve();
// Query scopes
Comment::resolved()->get();
Comment::unresolved()->get();
Comment::withTag('a11y')->get(); // carries this tag
Comment::withAnyTag(['a11y', 'copy'])->get(); // carries at least one
Comment::withAnyTag('a11y')->get(); // a single string also works
$comment->tags; // ['a11y', 'copy'] — always a list, never null
$comment->hasTags(); // bool
$task->comment('The CTA is unreadable on mobile', null, true, [
'priority' => 'blocker',
'tags' => ['a11y', 'mobile'],
]);
// Or directly
$comment->update(['priority' => 'must', 'tags' => ['copy']]);
// Check if bookmarked
$comment->isBookmarkedBy(); // current user
$comment->isBookmarkedBy($userId); // specific user
// On any model using HasComments
$task->toggleWatch(); // toggle for current user
$task->isWatchedBy(); // check if current user is watching
$task->isWatchedBy($userId); // check specific user
$task->commentWatchers(); // MorphMany relationship
blade
{{-- Read-only chips. Renders nothing when the comment has neither. --}}
<x-filament-comments::triage-chips :comment="$comment" />
{{-- The composer row. Point the *-method props at your own Livewire methods. --}}
<x-filament-comments::triage-composer
:priority="$this->priority"
:tags="$this->tags"
:options="$this->priorityOptions()"
:suggestions="$this->tagSuggestions()"
set-method="setPriority"
add-method="addTag"
remove-method="removeTag"
/>