Open
Description
Hi,
I'm currently trying to resolve an issue I have with how the API is structured. We have two different kind of users that are appearing in relationships. I'm looking for a way to differentiate the two user groups with resources. Something like this
'resources' => [
'employees' => \App\User::class,
'consultants' => \App\User::class,
]
$api->resource('assignments')
->only('index', 'read', 'update')
->relationships(function ($relations) {
$relations->hasOne('created-by', 'employees')->readOnly();
$relations->hasOne('supported-by', 'consultants');
}) //...
When querying the relationship /api/assignments/1/created-by
I would like to receive the underlying user object as "type": "employees"
and for /api/assignments/1/supported-by
as "type": "consultants"
.
Employees and consultants have their own schemas and adapters, but for both resources I'm getting "type": "employees"
.
Is there a solution in this package, or do I need to make a new model class for the different user types?
Metadata
Metadata
Assignees
Labels
No labels