A forum package for Filament apps that provides both admin and frontend resources for managing forums and forum posts.
- PHP 8.1+
- Laravel 10+
- Filament 4.0+
- Admin Resources: Full CRUD operations for forums and forum posts
- Frontend Resources: User-friendly interface for browsing and participating in forums
-
Require the package via Composer:
composer require tapp/filament-forum
-
Publish and run the migrations:
php artisan vendor:publish --tag="filament-forum-migrations" php artisan migrate
-
Publish the config file:
php artisan vendor:publish --tag="filament-forum-config"
-
Register the Plugins:
Add the admin plugin to your
AdminPanelProvider.php
:use Tapp\FilamentForum\Filament\ForumAdminPlugin; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugins([ ForumAdminPlugin::make(), // ... other plugins ]); }
Add the frontend plugin to your
AppPanelProvider.php
(or any frontend panel):use Tapp\FilamentForum\Filament\ForumPlugin; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugins([ ForumPlugin::make(), // ... other plugins ]); }
-
Add
HasFavoriteForumPost
trait to your User model:
use Tapp\FilamentForum\Models\Traits\HasFavoriteForumPost;
class User extends Authenticatable
{
// ...
use HasFavoriteForumPost;
// ...
}
- Add to your custom theme (usually
theme.css
) file:
To include the TailwindCSS styles used on frontend pages, add to your theme file:
@source '../../../../vendor/tapp/filament-forum';
That's it! The plugins will auto-register with Filament and be ready to use.
Optionally, you can publish the translation files with:
php artisan vendor:publish --tag="filament-forum-translations"
By default, the name
column of User
model is used for the user
relationship. You can customize it using the title-attribute
on filament-form.php
config file.
The 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).
Add the HasForumUserSearch
trait to your User model:
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tapp\FilamentForum\Traits\HasForumUserSearch;
class User extends Authenticatable
{
use HasForumUserSearch;
// Your existing model code...
}
Make sure your config/filament-forum.php
file points to the correct User
model:
'user' => [
'title-attribute' => 'name',
'model' => 'App\\Models\\User', // Your User model class
],
Override the trait methods in your User model to customize search behavior:
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Tapp\FilamentForum\Traits\HasForumUserSearch;
class User extends Authenticatable
{
use HasForumUserSearch;
/**
* Custom search that searches both name and email
*/
public static function getForumSearchResults(string $search): array
{
return static::query()
->where('name', 'like', "%{$search}%")
->orWhere('email', 'like', "%{$search}%")
->limit(50)
->pluck('name', 'id')
->all();
}
/**
* Custom option label display
*/
public static function getForumOptionLabel($value): ?string
{
$user = static::find($value);
return $user ? "{$user->name} ({$user->email})" : null;
}
}
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email [email protected].
The MIT License (MIT). Please see License File for more information.