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.
Public API
Section titled “Public API”__construct(array $attributes)
Section titled “__construct(array $attributes)”postType(): string
Section titled “postType(): string”fields(): array
Section titled “fields(): array”Logical field name => meta/ACF key.
relations(): array
Section titled “relations(): array”Logical name => [‘type’ => ‘belongsTo’, ‘model’ => class-string, ‘foreignKey’ => string].
casts(): array
Section titled “casts(): array”Attribute => ‘int’|‘bool’|‘string’|‘array’|DateTimeImmutable::class.
id(): int
Section titled “id(): int”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.