This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commentions is a Laravel package for Filament that adds commenting functionality to resources. It supports:
- Adding comments to any model
- Mentioning users in comments
- Comment reactions
- Comment permissions
- Event-driven notifications for mentions and reactions
- Polling for new comments
# Install PHP dependencies
composer install
# Run tests
./vendor/bin/pest
# Code style checks
composer lint:check
# Apply code style fixes
composer lint
# Static analysis
composer static-analysis# Install JS dependencies
npm install
# Build frontend assets for development with watch mode
npm run dev
# Build frontend assets for production
npm run build
# Individual build commands
npm run dev:scripts # Build JS in dev mode with watch
npm run build:scripts # Build JS for production
npm run dev:styles # Build CSS in dev mode with watch
npm run build:styles # Build CSS for production-
Models
Comment- The main comment modelCommentReaction- Model for storing reactions to commentsRenderableComment- Data object for non-comment items to display in comment lists
-
Contracts
Commentable- Interface for models that can receive commentsCommenter- Interface for user models that can create commentsRenderableComment- Interface for objects that can be rendered as comments
-
Traits
HasComments- For models that implementCommentableHasMentions- For Livewire components that support user mentionsHasPolling- For Livewire components that support polling for new comments
-
Livewire Components
Comment- Renders a single commentCommentList- Renders a list of commentsComments- Main component for the comment systemReactions- Component for reactions on comments
-
Filament Integration
CommentionsPlugin- Filament plugin for registering the packageCommentsEntry- Infolist component for displaying commentsCommentsAction- Action for displaying comments in FilamentCommentsTableAction- Table action for comments
-
Events
UserWasMentionedEvent- Dispatched when a user is mentioned in a commentCommentWasReactedEvent- Dispatched when a user reacts to a comment
The package is designed to be extensible. Key customization points:
- Override the Comment model
- Implement a custom CommentPolicy
- Register event listeners for mentions and reactions
- Customize the Commenter identification using
getCommenterName()
Tests use Pest PHP with Laravel and Livewire testing plugins. The testing setup:
- Uses SQLite in-memory database
- Creates test tables including comments, reactions, users, and posts
- Tests cover comment creation, editing, reactions, and permissions
When creating new features, ensure:
- Write Pest tests that cover the new functionality
- Test the feature with Filament integration
- Check stylistic consistency with existing code