- How do I install filament-comments in a Laravel project with Filament v2+?
- Run `composer require happytodev/filament-comments`, then execute `php artisan filament-comments:install` to set up migrations and configurations. Ensure your Filament admin panel is already configured and running Laravel 9/10 with PHP 8.1+.
- Can I attach comments to any Eloquent model or only specific ones?
- Yes, the package supports polymorphic relationships, allowing comments to be attached to any Eloquent model. Use the `commentable()` method on your model to enable comments, and the system will handle the rest via Filament’s resource integration.
- Does filament-comments work with Filament v3, or is it limited to v2?
- The package is designed for Filament v2+ and may not be fully compatible with Filament v3 due to its last release in 2022. Test thoroughly in a staging environment if upgrading, or check for community forks addressing v3 support.
- How do I customize comment validation or add approval workflows?
- Extend the `Comment` model to add validation rules (e.g., `is_approved`) or override the `rules()` method. For approval workflows, use Filament’s built-in state management or add a custom status column with soft-deletes for moderation.
- Will this package work if I’m using Inertia.js or Livewire alongside Filament?
- Yes, filament-comments integrates with Filament’s resource system, which is compatible with Inertia.js and Livewire. However, ensure your frontend setup supports Filament’s Blade components or JS interactions, as the package relies on Filament’s UI layer.
- Are there API endpoints for comments, or is this UI-only?
- filament-comments is UI-only and doesn’t include API routes. To expose comments via an API, create custom routes using Laravel’s HTTP controllers and query the `comments` table directly or via Eloquent relationships.
- How do I handle nested replies or threaded discussions?
- The package supports basic comment threads via Eloquent relationships, but nested replies require manual implementation. Use a `parent_id` column on the `comments` table and query with `with('replies')` to fetch hierarchies in your Filament resources.
- What Laravel versions are officially supported, and are there performance concerns?
- The package targets Laravel 9/10 and PHP 8.1+. Performance risks include N+1 queries if not optimized; eager-load relationships (e.g., `with('commentable')`) in your Filament resources to mitigate this.
- Can I use this package without Filament, or is it strictly tied to Filament admin?
- filament-comments is designed for Filament admin panels and won’t work standalone. For non-Filament Laravel apps, consider alternatives like `spatie/laravel-commentable` or build a custom solution using Eloquent and Blade.
- How do I migrate existing comments from another system (e.g., Laravel Nova) to filament-comments?
- Export your existing comments as JSON/CSV, then use Laravel’s `Comment` seeder or a data migration to insert records into the `comments` and `commentable_models` tables. Map fields like `user_id`, `content`, and `commentable_type` manually.