Skip to content

Future Improvements

This page documents the content resolution architecture and what has been implemented.

Implemented: Typed Block DTOs with Auto-Hydration

Section titled “Implemented: Typed Block DTOs with Auto-Hydration”

Status: ✅ Implemented in v1.1.0

The recommended approach has been fully implemented across all three packages. See Content Resolution and Block DTOs for the current system.

graph TD
    subgraph "v1.0.0 (Old)"
        A[ContentResolver] -->|groups by type| B[SectionContent]
        B -->|__get magic| C[BlockData]
        D[hydrateFromContent] -->|manual mapping| E[Component Properties]
        F[HasFieldLabels] -->|manual labels| G[Field Labels]
    end
    
    subgraph "v1.1.0 (New)"
        H[BlockCaster] -->|Eloquent cast| I[BlockCollection]
        I -->|typed access| J[BlockData]
        K[autoHydrate] -->|reflection| L[Component Properties]
        M[BlockSchemaExtractor] -->|auto-extract| N[Field Labels]
    end
    
    A -.->|removed| H
    B -.->|removed| I
    D -.->|removed| K
    F -.->|removed| M
Aspectv1.0.0v1.1.0
ResolutionContentResolver classBlockCaster Eloquent cast
ContainerSectionContentBlockCollection
Block access__get magic$block->get()
Null handlingNullBlockDatanull from first()
HydrationManual hydrateFromContent()Automatic autoHydrate()
LabelsManual fieldLabels()Auto-extracted BlockSchemaExtractor
OrderingGrouped by typeOriginal array order preserved
Livewire serializationManualpublic $blockData + hydrate()

See Migration Guide for step-by-step instructions to migrate from v1.0.0 to v1.1.0.


These approaches were considered but not chosen. They may be useful for understanding the design space.

Replace the monolithic resolution with a Laravel Pipeline:

graph LR
    A[Section] -->|pipeline| B[DecodeJson]
    B -->|pipeline| C[ResolveBlocks]
    C -->|pipeline| D[AttachSourceMaps]
    D -->|pipeline| E[ResolvedSection]

Pros: Extensible, testable stages, declarative property mapping Cons: More moving parts, over-engineered for most use cases

Each section type gets a dedicated View Model class:

graph LR
    A[Section] -->|SectionResolver| B[HeroViewModel]
    B -->|typed| C[Livewire Component]

Pros: Full type safety, IDE autocomplete, rich behavior Cons: More boilerplate, one class per section type


  • BlockCaster caching — Cache decoded BlockCollection within request lifecycle
  • Eager loading optimization — Reduce N+1 queries for sections with many blocks
  • Lazy block resolution — Only resolve blocks that are actually rendered
  • PHPStan integration — Add static analysis for block data access
  • IDE plugins — Auto-complete for BlockData::get() calls
  • GenericsBlockCollection<T> for typed collections
  • Custom BlockData DTOs — Register typed DTOs for specific block types
  • Pipeline-based resolution — Optional pipeline for complex transformations
  • Event system — Fires events during resolution for middleware-like behavior