laravel - Laravel APi 资源 whenLoaded
问题描述
我正在尝试使用 whenLoaded 加载模型关系,如下所示:
庭院资源
'latest_inspection' => new Inspection($this->whenLoaded('latestInspection'))
哪个工作正常,但是在检查资源上还有一些其他关系没有被包括在内:
检验资源
'completed_tasks' => TaskResource::collection($this->whenLoaded('tasks')),
'feedings' => FeedResource::collection($this->whenLoaded('feeds')),
如何确保这些也加载到 Yard 资源的 latestInspection 中?
解决方案
推荐阅读
- java - Spring 3.2 - 在 RestController 中处理 HttpClientError
- javascript - 找不到变量:LATITUDE、LONGITUDE 和 AnimatedRegion。window.navigator.geolocation.getCurrentPosition 也不可用
- c# - Azure.Messaging.ServiceBus:我应该在处置时从 ServiceBusProcessor 中删除 ProcessMessageAsync 处理程序吗?
- c# - post方法中的验证
- reactjs - 如何使用 Internet Explorer 11 访问本地网站?
- python - pywinauto 访问嵌套的子菜单
- hibernate - 将 Hibernate3 迁移到 Hibernate5,Formatter 类
- visual-studio-code - 带有“\”或“\\”的差异路径
- angular - 在移动设备上滚动时,角度触发器中的 ngx-slider 会不必要地触发
- jmx - 如何为咖啡因缓存激活 JMX