Search by

Polymorphic FAQ blocks for Orbis CMS content models.

Package info

gitlab.com/orbis-cms/faq

Issues

pkg:composer/orbis-cms/faq

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

0.0.2 2026-10-13 20:20 UTC

This package is auto-updated.

Last update: 2026-10-13 17:21:56 UTC


README

Polymorphic FAQ blocks for Orbis CMS content models, with an Orchid admin UI and a Blade component for the public side.

Any Eloquent model can opt into having a single FAQ block attached to it — it does not need to be a Page-backed (Pageable) model.

Requirements

  • PHP ^8.3
  • Laravel ^13.0
  • orbis-cms/core
  • Orchid Platform ^14.0

Installation

composer require orbis-cms/faq
php artisan migrate

The service provider is auto-discovered and registers:

  • migrations for faq_blocks and faq_items
  • translations under orbis-cms-faq::faq
  • the orbis-cms-faq::faq Blade component
  • an Orchid menu item, permission, and routes (platform.faq-blocks, .create, .edit)

Publish views or translations if you need to customize them:

php artisan vendor:publish --tag=orbis-cms-faq-views
php artisan vendor:publish --tag=orbis-cms-faq-translations

Making a model Faqable

Implement OrbisCms\Faq\Contracts\Faqable and use the HasFaq trait, which provides the faqBlock() relation:

use Illuminate\Database\Eloquent\Model;
use OrbisCms\Faq\Contracts\Faqable;
use OrbisCms\Faq\Models\Traits\HasFaq;

class Article extends Model implements Faqable
{
    use HasFaq;

    public static function alias(): string
    {
        return 'article';
    }

    public static function creationRules(): array
    {
        return ['name' => ['required', 'string']];
    }
}

Faqable only requires Contentable (alias() + validation rules) and faqBlock(): MorphOne — nothing page-specific. A model can additionally implement Pageable if it also needs its own page, but that's unrelated to attaching a FAQ block.

Rendering FAQ on the front end

<x-orbis-cms-faq::faq :faqable="$article" />

The component renders nothing if the model has no block or the block has no items, and otherwise pushes FAQPage schema.org structured data via orbis_schema_org().

FaqService

OrbisCms\Faq\Services\FaqService is the entry point for managing blocks programmatically:

MethodPurpose
resolveFaqable(string $type, int\|string $id)Resolves a Model&Faqable by morph type + key, validating it actually implements Faqable. Throws ValidationException otherwise.
assertNoExistingBlock(Model&Faqable $faqable)Throws ValidationException if the model already has a block.
blockFor(Model&Faqable $faqable)Returns the attached FaqBlock or null, via the faqBlock relation.
saveItems(FaqBlock $block, array $items)Creates/updates/reorders/deletes the block's items in one transaction, based on a submitted list.

Admin (Orchid)

  • OrbisCms\Faq\Orchid\FaqLink::toggle($faqable) builds a link to either edit the existing block or create one for that model — pass it directly to an Orchid screen's command bar for the entity you want to attach FAQ to.
  • Creation is entity-first: the link carries faqable_type / faqable_id for the specific model instance; there's no page picker or free-form lookup in the admin.
  • Guard access with the OrbisCms\Faq\Orchid\Permissions::FAQ_BLOCKS permission.

Testing

composer test
composer pint:test

License

MIT