Php 如何将in with()关系与父数据进行比较,如where has do
我提出这样的要求:Php 如何将in with()关系与父数据进行比较,如where has do,php,laravel,eloquent,Php,Laravel,Eloquent,我提出这样的要求: Event::where('team_id', Auth::user()->currentTeam->id) ->whereHas('animals', function ($query) use ($decodedId) { $query->where('animals.id', $decodedId) ->whereHas('health_items', function ($query) {
Event::where('team_id', Auth::user()->currentTeam->id)
->whereHas('animals', function ($query) use ($decodedId) {
$query->where('animals.id', $decodedId)
->whereHas('health_items', function ($query) {
$query->whereColumn('date_end', 'events.end');
});
})
多亏了whereColumn
,我将我的数据健康项目
与祖父母事件的数据进行了比较
$query->whereColumn('date_end', 'events.end');
它起作用了
只有WhereHas,我的响应中没有关系数据(它只是过滤掉事件
)
我试图通过添加一个来做同样的事情,但它不起作用
Event::where('team_id', Auth::user()->currentTeam->id)
->with(['animals' => function($query) use ($decodedId) {
$query->where('animals.id', $decodedId)
->with(['health_items' => function ($query) {
$query->whereColumn('date_end', 'events.end');
}]);
}])
返回错误:未知列“events.end”
是否有方法使用事件
表中的列筛选“健康项目”项目
多谢各位