laravel-responder
laravel-responder copied to clipboard
Load relation as
Is it possible to load relation as 'something'
For example I have these relations
protected $relations = [
'users' => UserTransformer::class,
'activeUsers' => UserTransformer::class
]
I'm sending get request to /teams?with=users or /teams?with=activeUsers and would like to have response from both requests as teams[].users[].
Hey! It’s currently not possible to rename relationships. However, you can create an includeUsers method that returns $team->activeUsers, however, I’m not sure how that would work with two relations referencing the same name. What should happen if you call teams?with=users,activeUsers?
Sorry, I havent replied this earlier. If I remember correctly we ended up with the solution you suggested, so with=users,activeUsers works fine