json-api-server icon indicating copy to clipboard operation
json-api-server copied to clipboard

Relationship meta

Open tobyzerner opened this issue 4 years ago • 0 comments

eg. pivot timestamps/data

ToMany::make('roles')
    // meta on the relationship object
    // $context->model is still the parent model
    ->meta([
        Meta::make('foo')->get('bar'),
    ])

    // meta on linkage resource identifier objects
    // $context->model is the related model
    ->linkageMeta([
        Meta::make('assignedAt')->get(fn($role) => $role->pivot->created_at),
    ]);

tobyzerner avatar May 25 '21 05:05 tobyzerner