laravel-responder icon indicating copy to clipboard operation
laravel-responder copied to clipboard

Parameters are not passing to the overwritten include method

Open wahlmika opened this issue 6 years ago • 3 comments

Kinda related to #111 because i am dealing with polymorphic relatioships too. I am trying to override include method inside the transformer and query parameters are not passing in to the function.

This is how i call the responder:

return Responder::success($notifications)->respond(200);

Heres how the relationships are declared:

protected $load = [
    'organisation' => OrganisationTransformer::class,
    'user' => UserTransformer::class,
    'relatedUser' => UserTransformer::class,
    'notificationTemplate' => NotificationTemplateTransformer::class,
    'notificationable' // This is the polymoprhic relationship
];

I have overridden the notificationable include same way as in the documentation, but the parameters are not passed to the function.

public function includeNotificationable(Notification $notification, Collection $params) 
{
    dd($params);
}

$params is always an empty collection

Collection {#517 #items: [] }

Am i doing something wrong or is this a bug?

wahlmika avatar Dec 05 '18 10:12 wahlmika

Hey @wahlmika, sorry for the late response here - did you find a solution to this?

flugg avatar Jan 30 '19 08:01 flugg

Thanks for the response @flugger. Unfortunately i didn't find a solution for this and i had to restructure the code, so that there were no polymorphic relations.

I would still like to know the answer to this if its possible, since there are projects where i'd like to use polymorphic relations.

wahlmika avatar Jan 31 '19 07:01 wahlmika

I'll find some time to research and see if I can replicate the issue and find a solution :)

flugg avatar Feb 01 '19 15:02 flugg