afea / filament-faq
FAQ module for the Afea Filament CMS package ecosystem: categorized FAQs with polymorphic attachment to any content model.
v0.1.0
2026-04-21 10:48 UTC
Requires
- php: ^8.4
- afea/filament-cms-core: @dev
- filament/filament: ^4.0
- illuminate/contracts: ^12.0
- illuminate/database: ^12.0
- illuminate/support: ^12.0
- laravel/prompts: ^0.3
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
FAQ module for the Afea Filament CMS package ecosystem.
Ships:
FaqandFaqCategorymodelsHasFaqstrait — add to any model to attach FAQs polymorphically through thefaqablespivot (carriesorderso each host orders its FAQs independently)FaqResource,FaqCategoryResource(Filament v4) with reorderable tablesFaqsRelationManager— drop into any resource whose model usesHasFaqsFaqPluginfor panel registrationafea:install:faqinstaller
Installation
composer require afea/filament-faq php artisan afea:install:faq
Register in AdminPanelProvider:
->plugin(\Afea\Cms\Faq\Filament\FaqPlugin::make())
Attaching FAQs to another model
1. Use the trait
use Afea\Cms\Faq\Concerns\HasFaqs; class BlogPost extends Model { use HasFaqs; }
2. Drop the relation manager into the host resource
use Afea\Cms\Faq\Filament\RelationManagers\FaqsRelationManager; class BlogPostResource extends Resource { public static function getRelations(): array { return [FaqsRelationManager::class]; } }
3. Query attached FAQs on the front-end
$post->faqs; // ordered by pivot `order` $post->activeFaqs(); // only active FAQs $post->syncFaqs([$idA, $idB]); // reorder atomically
Three common scenarios
1. Model override
class Faq extends \Afea\Cms\Faq\Models\Faq { public function scopeVerified(Builder $q): Builder { return $q->active()->whereNotNull('faq_category_id'); } }
'models' => ['faq' => \App\Models\Faq::class],
2. Bulk attach FAQs to every blog post
$post->syncFaqs(\Afea\Cms\Faq\Models\Faq::pluck('id')->all());
3. Render a FAQ section inside a Blade view
@foreach ($page->activeFaqs() as $faq) <details> <summary>{{ $faq->question }}</summary> <div class="prose">{!! $faq->answer !!}</div> </details> @endforeach