{"id":29843300,"url":"https://github.com/tappnetwork/filament-forum","last_synced_at":"2026-03-13T22:03:23.069Z","repository":{"id":305780381,"uuid":"1018158617","full_name":"TappNetwork/Filament-Forum","owner":"TappNetwork","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-11T21:10:32.000Z","size":331,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-12T02:06:05.282Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TappNetwork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-11T17:53:12.000Z","updated_at":"2026-02-18T14:00:54.000Z","dependencies_parsed_at":"2025-07-22T01:52:30.031Z","dependency_job_id":"5a6d89ef-984f-4143-baa1-6923945aefb3","html_url":"https://github.com/TappNetwork/Filament-Forum","commit_stats":null,"previous_names":["tappnetwork/filament-forum"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/TappNetwork/Filament-Forum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2FFilament-Forum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2FFilament-Forum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2FFilament-Forum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2FFilament-Forum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TappNetwork","download_url":"https://codeload.github.com/TappNetwork/Filament-Forum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TappNetwork%2FFilament-Forum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30477252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T20:45:58.186Z","status":"ssl_error","status_checked_at":"2026-03-13T20:45:20.133Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-29T15:42:49.140Z","updated_at":"2026-03-13T22:03:23.021Z","avatar_url":"https://github.com/TappNetwork.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Filament Forum\n\nA forum package for Filament apps that provides both admin and frontend resources for managing forums and forum posts.\n\n## Requirements\n\n- PHP 8.1+\n- Laravel 10+\n- Filament 4.x/5.x\n- Spatie Laravel Media Library\n\n## Features\n\n- **Admin Resources**: Full CRUD operations for forums and forum posts\n- **Frontend Resources**: User-friendly interface for browsing and participating in forums\n\n## Installation\n\n1. **Require the package via Composer:**\n\n   ```bash\n   composer require tapp/filament-forum\n   ```\n\n2. **Publish and run the migrations:**\n\n\u003e [!WARNING]  \n\u003e If you are using multi-tenancy please see the \"Multi-Tenancy Support\" instructions below **before** publishing and running migrations.\n\n   ```bash\n   php artisan vendor:publish --tag=\"filament-forum-migrations\"\n   php artisan migrate\n   ```\n\n3. **Publish the config file:**\n\n   ```bash\n   php artisan vendor:publish --tag=\"filament-forum-config\"\n   ```\n\n4. **Register the Plugins:**\n\n   ### Admin Panel (Backend)\n   \n   Add the admin plugin to your `AdminPanelProvider.php`:\n\n   ```php\n   use Tapp\\FilamentForum\\Filament\\ForumAdminPlugin;\n\n   public function panel(Panel $panel): Panel\n   {\n       return $panel\n           // ... other configuration\n           -\u003eplugins([\n               ForumAdminPlugin::make(),\n               // ... other plugins\n           ]);\n   }\n   ```\n\n   ### Frontend Panel (User-facing)\n   \n   Add the frontend plugin to your `AppPanelProvider.php` (or any frontend panel):\n\n   ```php\n   use Tapp\\FilamentForum\\Filament\\ForumPlugin;\n\n   public function panel(Panel $panel): Panel\n   {\n       return $panel\n           // ... other configuration\n           -\u003eplugins([\n               ForumPlugin::make(),\n               // ... other plugins\n           ]);\n   }\n   ```\n\n5. User model requirements\n\n- Ensure your User model has a `name` attribute\n\n- Add the `ForumUser` trait to your `User` model:\n\n```php\nuse Tapp\\FilamentForum\\Traits\\ForumUser;\n\nclass User extends Authenticatable\n{\n    // ...\n    use ForumUser;\n    // ...\n}\n```\n\nThe `ForumUser` trait provides:\n- `forums()` relationship - Get all forums the user is assigned to\n- `favoriteForumPosts()` relationship - Get all favorite forum posts\n- `getMentionableUsers()` method - Customize which users are mentionable (see \"Custom Mentionables\" below)\n- `hasCustomForumSearch()`, `getForumSearchResults()`, `getForumOptionLabel()` methods - Custom search functionality (see \"Custom User Model, Attribute, and Search Functionality\" below)\n- `isForumAdmin()` method - Override to grant admin access to hidden forums (defaults to `false`)\n- `canCreateForum()` method - Controls forum creation permissions (see \"Forum Creation Permissions\" below)\n\n6. Add to your custom theme (usually`theme.css`) file:\n\nTo include the TailwindCSS styles used on frontend pages, add to your theme file:\n\n```css\n@source '../../../../vendor/tapp/filament-forum';\n```\n\nThat's it! The plugins will auto-register with Filament and be ready to use.\n\nOptionally, you can publish the translation files with:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-forum-translations\"\n```\n\n## Multi-Tenancy Support\n\nFilament Forum includes built-in support for multi-tenancy, allowing you to scope forums and forum posts to specific tenants (e.g., teams, organizations, workspaces).\n\n### ⚠️ Important: Enable Tenancy Before Migrations\n\n**You MUST configure and enable tenancy in the config file BEFORE running the migrations.** The migrations check the tenancy configuration to determine whether to add tenant columns to the database tables. If you enable tenancy after running migrations, you'll need to manually add the tenant columns to your database.\n\n### Setup\n\n#### 1. Configure Tenancy (Before Migrations!)\n\nEdit your `config/filament-forum.php` file **before** running the migrations:\n\n```php\n'tenancy' =\u003e [\n    // Enable tenancy support\n    'enabled' =\u003e true,\n\n    // The Tenant model class (e.g., App\\Models\\Team::class, App\\Models\\Organization::class)\n    'model' =\u003e \\App\\Models\\Team::class,\n\n    // The tenant relationship name (optional)\n    // Defaults to snake_case of tenant model class name\n    // For example: Team::class -\u003e 'team', Organization::class -\u003e 'organization'\n    'relationship_name' =\u003e 'team',\n\n    // The tenant column name (optional)\n    // Defaults to snake_case of tenant model class name + '_id'\n    // For example: Team::class -\u003e 'team_id', Organization::class -\u003e 'organization_id'\n    'column' =\u003e 'team_id',\n],\n```\n\n#### 2. Run Migrations\n\nNow you can safely run the migrations, which will include the tenant columns:\n\n```bash\nphp artisan vendor:publish --tag=\"filament-forum-migrations\"\nphp artisan migrate\n```\n\nThe following tables will include your tenant column (e.g., `team_id`):\n- `forums`\n- `forum_posts`\n- `forum_comments`\n- `forum_comment_reactions`\n- `forum_post_views`\n\n#### 3. Configure Your Filament Panel\n\nMake sure tenancy is enabled on your Filament panel (e.g., in `AdminPanelProvider.php`):\n\n```php\nuse Filament\\Panel;\nuse App\\Models\\Team;\n\npublic function panel(Panel $panel): Panel\n{\n    return $panel\n        // ... other configuration\n        -\u003etenant(Team::class)\n        -\u003eplugins([\n            ForumAdminPlugin::make(),\n            // ... other plugins\n        ]);\n}\n```\n\n#### 4. Implement Required Contracts on Your User Model\n\nYour User model needs to implement Filament's tenancy contracts (using `teams` tenant in this example):\n\n```php\nuse Filament\\Models\\Contracts\\FilamentUser;\nuse Filament\\Models\\Contracts\\HasTenants;\nuse Filament\\Panel;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\nuse Illuminate\\Support\\Collection;\n\nclass User extends Authenticatable implements FilamentUser, HasTenants\n{\n    // Define the relationship to your tenant model (eg. teams)\n    public function teams(): BelongsToMany\n    {\n        return $this-\u003ebelongsToMany(Team::class);\n    }\n\n    // Required by FilamentUser\n    public function canAccessPanel(Panel $panel): bool\n    {\n        return true; // Customize as needed\n    }\n\n    // Required by HasTenants\n    public function getTenants(Panel $panel): Collection\n    {\n        return $this-\u003eteams;\n    }\n\n    // Required by HasTenants\n    public function canAccessTenant(Model $tenant): bool\n    {\n        return $this-\u003eteams()-\u003ewhereKey($tenant)-\u003eexists();\n    }\n}\n```\n\n#### 5. Implement Required Contracts on Your Tenant Model\n\nYour Tenant model (e.g., `Team`) should implement Filament's `HasName` contract:\n\n```php\nuse Filament\\Models\\Contracts\\HasName;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany;\n\nclass Team extends Model implements HasName\n{\n    // Define the inverse relationship\n    public function users(): BelongsToMany\n    {\n        return $this-\u003ebelongsToMany(User::class);\n    }\n\n    // Required by HasName\n    public function getFilamentName(): string\n    {\n        return $this-\u003ename;\n    }\n}\n```\n\n### How It Works\n\nOnce tenancy is enabled:\n\n1. **Automatic Scoping**: All forum and forum post queries are automatically scoped to the current tenant\n2. **Automatic Association**: When creating forums or posts, they're automatically associated with the current tenant\n3. **Access Control**: Users can only access forums and posts belonging to their current tenant\n\n### URL Structure with Tenancy\n\nWith tenancy enabled, your Filament panel URLs will include the tenant identifier:\n\n```\n/admin/{tenant-slug}/forums\n/admin/{tenant-slug}/forum-posts\n```\n\nFor example:\n```\n/admin/acme-company/forums\n/admin/acme-company/forum-posts\n```\n\n### Disabling Tenancy\n\nTo disable tenancy, simply set `'enabled' =\u003e false` in your `config/filament-forum.php`:\n\n```php\n'tenancy' =\u003e [\n    'enabled' =\u003e false,\n    'model' =\u003e null,\n],\n```\n\n**Note**: If you've already run migrations with tenancy enabled, the tenant columns will remain in your database. You'll need to handle existing tenant-scoped data appropriately or create a migration to remove the columns if needed.\n\n### Important Notes\n\n- **Migrations First**: Always configure tenancy before running migrations\n- **Data Migration**: If you enable tenancy on an existing installation, you'll need to manually add tenant columns and populate them with appropriate values\n- **Testing**: When testing with tenancy enabled, ensure your factories and seeders properly associate records with tenants\n\nFor more detailed information about implementing multi-tenancy in Filament, see the [official Filament tenancy documentation](https://filamentphp.com/docs/4.x/users/tenancy).\n\n## Custom User Model, Attribute, and Search Functionality\n\nBy default, the `name` column of `User` model is used for the `user` relationship. You can customize it using the  `title-attribute` on `filament-forum.php` config file.\n\nThe Filament Forum plugin also supports custom search functionality for user selects in forms and filters. This allows you to customize which users' columns are used to search and display in dropdowns (eg. if your `User` model doesn't have a `name` column).\n\n### Configure Your User Model Class\n\nMake sure your `config/filament-forum.php` file points to the correct `User` model:\n\n```php\n'user' =\u003e [\n    'title-attribute' =\u003e 'name',\n    'model' =\u003e 'App\\\\Models\\\\User',  // Your User model class\n],\n```\n\n### Customize the Search Methods\n\nOverride the trait methods in your User model to customize search behavior:\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse Tapp\\FilamentForum\\Traits\\ForumUser;\n\nclass User extends Authenticatable\n{\n    use ForumUser;\n    \n    /**\n     * Custom search that searches both name and email\n     */\n    public static function getForumSearchResults(string $search): array\n    {\n        return static::query()\n            -\u003ewhere('name', 'like', \"%{$search}%\")\n            -\u003eorWhere('email', 'like', \"%{$search}%\")\n            -\u003elimit(50)\n            -\u003epluck('name', 'id')\n            -\u003eall();\n    }\n    \n    /**\n     * Custom option label display\n     */\n    public static function getForumOptionLabel($value): ?string\n    {\n        $user = static::find($value);\n        \n        return $user ? \"{$user-\u003ename} ({$user-\u003eemail})\" : null;\n    }\n}\n```\n\n## Custom Mentionables\n\nYou can customize which users are mentionable by overriding the `getMentionableUsers()` method in your `User` model:\n\n```php\n// In your User model\npublic static function getMentionableUsers()\n{\n    // Only active users\n    return static::where('is_active', true)-\u003eget();\n}\n```\n\n## Forum Access Control\n\nForums can be set as public (visible to all logged-in users) or hidden (only visible to assigned users). Forum admins can see all hidden forums regardless of assignment.\n\n### Forum Creation Permissions\n\nBy default, forum creation is **disabled** for security. To enable forum creation, you must add the `ForumUser` trait to your User model and override the `canCreateForum()` method:\n\n```php\n// In your User model\nuse Tapp\\FilamentForum\\Traits\\ForumUser;\n\nclass User extends Authenticatable\n{\n    use ForumUser;\n    \n    /**\n     * Determine if the user can create forums.\n     * Override this method to enable forum creation with custom logic.\n     */\n    public function canCreateForum(): bool\n    {\n        // Example: Using Spatie Laravel Permission\n        return $this-\u003ehasPermissionTo('create forum');\n        \n        // Example: Using roles\n        // return $this-\u003ehasRole(['Admin', 'Moderator']);\n        \n        // Example: Allow all authenticated users\n        // return true;\n        \n        // Example: Custom logic\n        // return $this-\u003eis_verified \u0026\u0026 $this-\u003ereputation_points \u003e= 100;\n    }\n}\n```\n\n**Important**: \n- Make sure to add the `ForumUser` trait to your User model (see step 5 in Installation)\n- The trait provides a default implementation that returns `false` for security\n- You must explicitly override `canCreateForum()` to enable forum creation\n\nThe `canCreateForum()` method is:\n- **Checked automatically** when displaying the \"Create\" button on the forums list page\n- **Enforced** when accessing the forum creation page\n- **Secure by default** - forum creation is disabled unless explicitly enabled\n\n### Setting Forum Access\n\nIn the admin panel, you can set a forum as hidden by checking the \"Hidden Forum\" checkbox. Hidden forums will only be visible to:\n- Users who are explicitly assigned to the forum\n- Forum admins (users where `isForumAdmin()` returns `true`)\n\n### Forum Admin Access\n\nOverride the `isForumAdmin()` method in your User model to grant admin access:\n\n```php\n// In your User model\npublic function isForumAdmin(): bool\n{\n    // Example: Grant admin access based on roles\n    return $this-\u003ehasRole('Admin') || $this-\u003ehasRole('Forum Admin');\n}\n```\n\nForum admins can see and access all hidden forums, even if they're not assigned to them.\n\n## User Avatar\n\nOptionally, implements Filament's `HasAvatar` interface:\n\n```php\nuse Filament\\Models\\Contracts\\HasAvatar;\n\nclass User extends Authenticatable implements HasAvatar\n{   \n    public function getFilamentAvatarUrl(): ?string\n    {\n        return $this-\u003eavatar_url;\n    }\n}\n```\n\n## Events Dispatched\n\nThe plugin automatically dispatches events when a forum is created, a comment is created, reacted to, or when users are mentioned in a comment:\n\n- `Tapp\\FilamentForum\\Events\\ForumCommentCreated`\n- `Tapp\\FilamentForum\\Events\\ForumPostCreated`\n- `Tapp\\FilamentForum\\Events\\CommentWasReacted`\n- `Tapp\\FilamentForum\\Events\\UserWasMentioned`\n\n### UserWasMentioned Event\n\nYou can send a notification by listening to the `UserWasMentioned` event. The event structure is:\n\n```php\nuse Tapp\\FilamentForum\\Events\\UserWasMentioned;\n\n// The event contains:\n// - $mentionedUser: The user who was mentioned\n// - $comment: The ForumComment instance\n```\n\nExample usage:\n\n```php\nnamespace App\\Listeners;\n\nuse App\\Notifications\\UserMentionedNotification;\nuse Illuminate\\Contracts\\Queue\\ShouldQueue;\nuse Illuminate\\Notifications\\Notification;\nuse Illuminate\\Queue\\InteractsWithQueue;\nuse Tapp\\FilamentForum\\Events\\UserWasMentioned;\n\nclass SendUserMentionedNotification implements ShouldQueue\n{\n    use InteractsWithQueue;\n\n    public function handle(UserWasMentioned $event): void\n    {\n        $mentionedUser = $event-\u003ementionedUser;\n        $comment = $event-\u003ecomment;\n        \n        // Send notification to the mentioned user\n        $mentionedUser-\u003enotify(new UserMentionedNotification($comment));\n        \n        // Or dispatch a custom notification\n        Notification::make()\n            -\u003etitle('You were mentioned in a comment')\n            -\u003ebody(\"You were mentioned by {$comment-\u003eauthor-\u003ename}\")\n            -\u003esendToDatabase($mentionedUser);\n    }\n}\n```\n\nThis should work with [Laravel's event auto-discovery](https://laravel.com/docs/11.x/events#registering-events-and-listeners). If not, you can register your listener on `EventServiceProvider`:\n\n```php\nuse Tapp\\FilamentForum\\Events\\UserWasMentioned;\nuse App\\Listeners\\SendUserMentionedNotification;\n\nprotected $listen = [\n    UserWasMentioned::class =\u003e [\n        SendUserMentionedNotification::class,\n    ],\n];\n```\n\nCustom notification example:\n\n```php\nnamespace App\\Notifications;\n\nuse Illuminate\\Notifications\\Messages\\MailMessage;\nuse Illuminate\\Notifications\\Notification;\nuse Tapp\\FilamentForum\\Models\\ForumComment;\n\nclass UserMentionedNotification extends Notification\n{\n    public function __construct(\n        public ForumComment $comment\n    ) {}\n\n    public function via($notifiable)\n    {\n        return ['database', 'mail'];\n    }\n\n    public function toDatabase($notifiable)\n    {\n        return [\n            'title' =\u003e 'You were mentioned',\n            'body' =\u003e \"You were mentioned in a comment by {$this-\u003ecomment-\u003eauthor-\u003ename}\",\n            'comment_id' =\u003e $this-\u003ecomment-\u003eid,\n            'forum_post_id' =\u003e $this-\u003ecomment-\u003eforumPost-\u003eid,\n        ];\n    }\n\n    public function toMail($notifiable)\n    {\n        return (new MailMessage)\n            -\u003esubject('You were mentioned in a forum comment')\n            -\u003eline(\"You were mentioned in a comment by {$this-\u003ecomment-\u003eauthor-\u003ename}\")\n            -\u003eaction('View Comment', route('forum.posts.show', $this-\u003ecomment-\u003eforumPost));\n    }\n}\n```\n\n## Testing\n\n### Publishing Tests to Your Application\n\nYou can publish ready-to-use test files to your application to test the Filament Forum functionality:\n\n```bash\nphp artisan filament-forum:install-tests\n```\n\nThis will copy test files to your `tests/Feature` directory:\n- `FilamentForumTest.php` - Basic forum and post functionality tests\n- `FilamentForumTenancyTest.php` - Multi-tenancy specific tests (automatically skipped if tenancy is disabled)\n\nThe tests are written using [Pest](https://pestphp.com/) and automatically use your configured User and Tenant models from `config/filament-forum.php`.\n\n**Requirements:**\n- Pest testing framework: `composer require pestphp/pest --dev`\n- Model factories for your User model and Tenant model (if using tenancy)\n\n**Run the tests:**\n```bash\nphp artisan test --filter=FilamentForum\n```\n\nSee the published tests for more examples of how to test the plugin in your application.\n\nRead more about publishing tests [here](PUBLISH_TESTS.md).\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nIf you discover any security-related issues, please email security@tappnetwork.com.\n\n## Credits\n\n-  [Tapp Network](https://github.com/TappNetwork)\n-  Comments inspired by [Commentions](https://github.com/kirschbaum-development/commentions)\n-  [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappnetwork%2Ffilament-forum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftappnetwork%2Ffilament-forum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftappnetwork%2Ffilament-forum/lists"}