Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Comments Laravel Package

happytodev/filament-comments

Filament plugin that adds comment functionality to your admin panel, with current support focused on OrbitPHP. Includes an install command and publishable config to get started quickly, plus tests and changelog for ongoing maintenance.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require happytodev/filament-comments
    

    Publish the package assets and config:

    php artisan vendor:publish --provider="Happytodev\FilamentComments\FilamentCommentsServiceProvider" --tag="filament-comments-config"
    php artisan vendor:publish --provider="Happytodev\FilamentComments\FilamentCommentsServiceProvider" --tag="filament-comments-migrations"
    

    Run migrations:

    php artisan migrate
    
  2. Register the Plugin Add to app/Providers/Filament/AdminPanelProvider.php:

    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugins([
                \Happytodev\FilamentComments\FilamentCommentsPlugin::make(),
            ]);
    }
    
  3. First Use Case: Enable Comments on a Resource Add the HasComments trait to your resource model:

    use Happytodev\FilamentComments\Concerns\HasComments;
    
    class Post extends Model
    {
        use HasComments;
    }
    

    Then, in your Filament resource class, add the HasCommentsTable trait:

    use Happytodev\FilamentComments\Concerns\HasCommentsTable;
    
    class PostResource extends Resource
    {
        use HasCommentsTable;
    }
    

Implementation Patterns

Core Workflows

  1. Commenting on Records

    • The package auto-generates a "Comments" tab in your Filament resource.
    • Users can add, edit, and delete comments via the UI.
    • Example: A blog post resource will have a dedicated comments section.
  2. Nested Comments

    • Enable threaded replies by configuring the threaded option in the config:
      'threaded' => true,
      
    • Use the reply() method in your resource actions:
      public static function getCommentActions(Comment $comment): array
      {
          return [
              Tables\Actions\Action::make('reply')
                  ->label('Reply')
                  ->action(function (Comment $comment) {
                      // Handle reply logic
                  }),
          ];
      }
      
  3. Customizing Comment Fields

    • Extend the default comment form by publishing and modifying the view:
      php artisan vendor:publish --tag="filament-comments-views"
      
    • Override the createCommentForm method in your resource:
      public function createCommentForm(): array
      {
          return [
              Forms\Components\Textarea::make('body')
                  ->required()
                  ->maxLength(1000),
              Forms\Components\Select::make('status')
                  ->options(['draft', 'published'])
                  ->default('draft'),
          ];
      }
      
  4. Moderation and Approval

    • Use the status field to implement approval workflows:
      public function table(Table $table): Table
      {
          return $table
              ->columns([
                  // ...
                  Tables\Columns\SelectColumn::make('status')
                      ->options(['draft' => 'Draft', 'published' => 'Published']),
              ]);
      }
      
    • Add bulk actions for moderation:
      public static function getCommentBulkActions(): array
      {
          return [
              Tables\Actions\BulkAction::make('publish')
                  ->action(function (Collection $records) {
                      $records->update(['status' => 'published']);
                  }),
          ];
      }
      
  5. Notifying Users

    • Listen for comment events (e.g., CommentCreated) to trigger notifications:
      public function boot()
      {
          Comment::created(function ($comment) {
              Notification::route('mail', $comment->commentable->user->email)
                  ->notify(new NewCommentNotification($comment));
          });
      }
      

Integration Tips

  1. Leverage Filament’s Existing Features
    • Use Filament’s built-in actions (e.g., EditAction, DeleteAction) for comments:
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky