dingo / api

A RESTful API package for the Laravel and Lumen frameworks.
BSD 3-Clause "New" or "Revised" License
9.33k stars 1.25k forks source link

nested eager loading includes not work #1645

Open liyu001989 opened 5 years ago

liyu001989 commented 5 years ago
Q A
Bug? yes
New Feature? no
Framework Laravel Lumen
Framework version 5.8.10
Package version 2.2.3
PHP version 7.3.3

Actual Behaviour

Models:

user has many Topics,Tpoic has many replies。when I request /api/replies?include=topic.user

only topic eagered,becase those codes : https://github.com/dingo/api/blob/v2.0.0/src/Transformer/Adapter/Fractal.php#L93-L96

just load topic。

Expected Behaviour

topic.user will be eagered

Steps to Reproduce

There is a public repo: https://github.com/summerblue/larabbs/tree/api

ReplyTransformer: https://github.com/summerblue/larabbs/blob/api/app/Transformers/ReplyTransformer.php

specialtactics commented 5 years ago

Did you try topic.user inside the $availableIncludes array?