Skip to content
Corex

Model

Corex\Models\Model · class · Core layer

A read-only value object describing one entity’s shape (spec FR-001–FR-003). Holds typed attributes only — no query logic, no data-source calls, no persistence (writes go through the Repository, which returns a fresh Model). A subclass declares its post type, field map, optional relations, and casts.

Logical field name => meta/ACF key.

Logical name => [‘type’ => ‘belongsTo’, ‘model’ => class-string, ‘foreignKey’ => string].

Attribute => ‘int’|‘bool’|‘string’|‘array’|DateTimeImmutable::class.

get(string $attribute, mixed $default): mixed

Section titled “get(string $attribute, mixed $default): mixed”

withAttribute(string $attribute, mixed $value): static

Section titled “withAttribute(string $attribute, mixed $value): static”

Return a NEW Model with one attribute added/replaced (immutable copy). Used to attach an eager-loaded relation without mutating the original.