Repository navigation
CrudResourceConfig
Pair\Api\CrudResourceConfig is the typed internal value object used by Pair v4 auto-CRUD resources.
It centralizes CRUD defaults and keeps legacy array configs compatible at public boundaries.
Before this object, ApiExposable, CrudController, QueryFilter, and SpecGenerator read the same config keys directly from arrays. That made defaults easy to duplicate and array-key mistakes easy to miss.
CrudResourceConfig gives framework internals typed accessors while preserving existing apiConfig(): array and crud(..., array $config) usage.
Applications can keep writing array config:
$this->crud('faqs', \App\Models\Faq::class, [
'readModel' => \App\Api\ReadModels\FaqReadModel::class,
'sortable' => ['createdAt'],
'perPage' => 20,
]);The framework normalizes that array through CrudResourceConfig.
Advanced code may pass an explicit config object:
use Pair\Api\CrudResourceConfig;
$config = CrudResourceConfig::fromArray([
'readModel' => \App\Api\ReadModels\FaqReadModel::class,
'perPage' => 20,
]);
$this->crud('faqs', \App\Models\Faq::class, $config);Default values are centralized in CrudResourceConfig:
-
readModel:null -
resource:null -
searchable:[] -
sortable:[] -
filterable:[] -
includes:[] -
includeReadModels:[] -
includeResources:[] -
includePreloader:null -
perPage:20 -
maxPerPage:100 -
rules:['create' => [], 'update' => []] -
defaultSort:null
from(array|CrudResourceConfig|null $config): CrudResourceConfigfromArray(array $config): CrudResourceConfigtoArray(): arrayreadModel(): ?stringresource(): ?stringsearchable(): arraysortable(): arrayfilterable(): arrayincludes(): arrayincludeReadModels(): arrayincludeResources(): arrayincludePreloader(): ?stringperPage(): intmaxPerPage(): intrules(): arraycreateRules(): arrayupdateRules(): arraydefaultSort(): ?string
- Comments and docblocks are explanatory only; config behavior is encoded in
CrudResourceConfig, not in comments. -
getApiConfig()still returns an array for compatibility. -
ApiExposable::getCrudResourceConfig()exposes the typed config for internal framework consumers and uses CrudResourceMetadata to avoid repeated normalization. -
CrudController,SpecGenerator, andQueryFilterconsume the typed config internally, even when the original input was an array. -
includePreloaderpoints to an optional CrudIncludePreloader implementation for bulk include loading on collection responses.
See also: ApiExposable, CrudController, CrudIncludePreloader, CrudResourceMetadata, QueryFilter, SpecGenerator.
Maintained by Viames Marino — VM Ingegneria · Professional enquiries
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4