page-sections-lord
Design and build section-based landing and content pages with Filament Builder in Laravel.
Files2
View on GitHubSKILL.mdskills/page-sections-lord/SKILL.md
GitHub[SKILL] page-sections-lord [OBJ] Design, scaffold, and operate reusable page sections and landing pages via Filament/Laravel. [RULES]
- [CMD] IDs: Filament
/filamentphp/filament; Filament Spatie Translatable Plugin/filamentphp/spatie-laravel-translatable-plugin; Spatie Translatable/spatie/laravel-translatable; Spatie Query Builder/spatie/laravel-query-builder; Filament Fabricator/z3d0x/filament-fabricator(block-based alternative). - [REQ] Page-builder pattern core:
Pagemodel with JSONcontent; translatabletitle,slug,description,content,meta_title,meta_desc,meta_keywords; parentpage_idself-reference;is_home,is_header,is_footerflags. - [REQ] Filament
Builderforcontent.{locale}; oneBlock::make('X_section')per section with a unique type key and a schema that matches the frontend component props. - [REQ] Standard block shape:
{ "type": "hero_section", "data": { ... } }; keepdataflat; use consistent image key names (image,background_image,*_image,logo,icon). - [REQ] Static pages:
StaticPagemodel withtypeand translatabletitle/content/slug; seedprivacy-policy,terms-of-service,faqs,ai-ethics,about-us; embed via astatic_*_sectionblock that maps type to slug. - [REQ] API:
PageControllerwith index (Spatie\QueryBuilder),show($slug)by locale, andsections($slug); castcontentto array; recursively transform image keys to fullStorage::disk('s3')->url()orasset(Storage::url(...))URLs. - [REQ] i18n: Spatie
HasTranslationsonPageandStaticPage; Filament translatable tabs; lookup byslug->{locale}with fallback to default locale;app()->getLocale()in controller. - [REQ] Common blocks: hero, destinations, testimonials, vision, mission, story_stats, tech_features, team, cta, contact, global_presence, faqs, privacy_policy, terms_of_service, ai_ethics, about_us. Add new blocks via new
BlockinPageFormand a matching frontend component. - [REQ] Image handling:
FileUpload::image()with directoryassets/images/pages/{section}; store only relative paths in DB; API returns absolute URLs; preview images underpublic/assets/images/builder-previews/{section}.pngfor Filament block labels. - [REQ] Reusability: when blocks need cross-page reuse, tenant-scoping, or user-defined block types, migrate to
page_sectionspivot orfilament-fabricatorblock registry; keep block shapetype/datato ease migration. - [REQ] New projects: start from
skills/page-sections-lord/templates/page-builder-spec.md; follow the scaffold order: migrations → models → Filament resource/form → API controller/resource → routes → frontend section components → static pages seeder. - [REQ] Security/RBAC: use
filament-shieldfor admin permissions; validatesluguniqueness per locale; never expose one tenant's page/section to another; apply tenant scope if multi-tenancy. - [REQ] Cross-stack questions query
page-sections-lord,backend-frameworks-lord,frontend-frameworks-lord, andmariadb-lordif database-specific; explain the rationale. - [REQ] Status Enum for Pages (Sky pattern):
enum PageStatus: string implements HasColor, HasIcon, HasLabelwith 7 states: Publish, Future, Draft, Auto, Pending, Private, Trash. ⛔ NEVER string status column. Use backed enum with colors/icons. Filter scopes:scopePublished,scopeSticky,scopeDraft. - [REQ] Tab-based Page Form (Sky pattern):
Tabs::make('content_tabs')with logical tabs: Content (title + editor), SEO (description + slug + meta), Visibility (status + password + published_at + sticky_until), Media (featured image upload/URL toggle). ⛔ NEVER one long form. Split by domain concern. - [REQ] Upload/URL Toggle for Images (Sky pattern):
ToggleButtons::make('image_type')->options(['upload' => 'Upload', 'url' => 'URL'])->live()+SpatieMediaLibraryFileUpload::make('image_upload')->visible(fn(Get $get) => $get('image_type') === 'upload')+TextInput::make('image_url')->url()->visible(fn(Get $get) => $get('image_type') === 'url'). Flexible media input per block. - [REQ] Configurable Editor (Filament-Blog pattern):
HasContentEditortrait +getContentEditor(string $field)method.config('page-sections.editor')selects RichEditor / MarkdownEditor / TinyEditor.config('page-sections.toolbar_buttons')for toolbar. Pluggable without code changes. - [REQ] Navigation Builder (Sky pattern):
Navigationmodel with JSONitemsfield.ViewField::make('items')->default([])->view('navigation-builder')custom blade view. Drag-drop menu builder in admin. Locations config: header, footer, footer-2, etc. - [REQ] Search Highlighting (Sky pattern):
highlightSearchResults(Collection $collection, ?string $search): Collectiontrait. Highlight matched terms in title/content for frontend search.parsing(string $text, array $terms): stringhelper. - [REQ] Spatie Media Library (Sky pattern):
InteractsWithMedia+ collections per section type (posts,pages,sections).SpatieMediaLibraryFileUploadwith disk from plugin config:SkyPlugin::get()->getUploadDisk().$model->getFirstMediaUrl('collection')for URLs. ⛔ NEVER plainFileUploadfor complex media. Use collections + conversions. - [REQ] Spatie Tags with Types (Sky pattern):
SpatieTagsInput::make('tags')->type('section_tag')for typed taxonomy. Differentiate tags vs categories viatypeparameter.SelectFilter::make('tags')->multiple()->relationship('tags', 'name')for table filters. - [REQ] Password Protection (Sky pattern):
status === 'private'+passwordfield on Page model.requirePassword(): Attributechecks status + password presence. Frontend prompts password before showing private pages. - [REQ] Sticky/Scheduling (Sky pattern):
sticky_untildate column for sticky posts with expiry.published_atdatetime for scheduling.scopeSticky(Builder $q): $q->whereNotNull('sticky_until')->whereDate('sticky_until', '>=', now()).scopePublished: status=publish + published_at <= now. - [REQ] Parent-Child Pages (Sky pattern):
parent_idself-reference +orderinginteger.Select::make('parent_id')->options(Post::where('post_type', 'page')->pluck('title', 'id')). Hierarchical page structure. Frontend renders tree. - [REQ] FAQ Schema (MVPable pattern):
faqSchema(array $faqs): arraygenerates JSON-LD{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[...]}. Embed via<script type="application/ld+json">. Google rich results for FAQ sections. - [REQ] Breadcrumb Schema (MVPable pattern):
breadcrumbSchema(array $breadcrumbs): arraygenerates JSON-LDBreadcrumbList.{"@type":"ListItem","position":N,"name":"...","item":"..."}. Google sitelinks breadcrumb display. - [REQ] Article Schema (MVPable pattern):
articleSchema(headline, description, image, publishedTime, modifiedTime, author)generates JSON-LDArticle. For blog/news sections. Google News inclusion. - [REQ] Organization Schema (MVPable pattern):
organizationSchema(): arraygenerates JSON-LDOrganizationwithname,legalName,url,logo,sameAs(social links). For site-wide structured data. - [REQ] Action Groups (Sky pattern):
ActionGroup::make([EditAction::make('edit'), Action::make('Open')->url()->openUrlInNewTab(), DeleteAction::make('delete'), ForceDeleteAction::make(), RestoreAction::make()])for consistent record actions across all page resources. - [REQ] Navigation Badges (Sky pattern):
getNavigationBadge(): ?stringreturns(string) Model::count(). Respect visibility config:SkyPlugin::getNavigationBadgesVisibility(static::class). Show counts in sidebar navigation. - [REQ] Create Option Forms (Filament-Blog pattern):
Select::make('category_id')->relationship('category', 'name')->createOptionForm([TextInput::make('name'), TextInput::make('slug')])->preload()->searchable(). Inline creation without leaving page. Reduces context switching. - [REQ] Auto-slug Generation (Sky/Filament-Blog pattern):
TextInput::make('title')->live(onBlur: true)->afterStateUpdated(fn(Set $set, $state, $context) => $context === 'edit' ?: $set('slug', Str::slug($state))). ⛔ NEVER overwrite slug on edit.