gpt4 book ai didi

php - Laravel `Item` 有很多,只有在过去时才返回

转载 作者:行者123 更新时间:2023-11-29 02:50:07 25 4
gpt4 key购买 nike

在我的项目中,hire 可以有很多 hire_days。每个 hire_day 都有一个 startend 时间戳。我想创建一个查询,它将只返回所有关联的 hire_day.end 时间过去的雇员。到目前为止,我的查询:

$hires = Hires::join('hires_days', function ($join) {
$join->on('hire_id', '=', 'hires.id');
})
->select('hires.id', 'hires.account_id', 'hires.job_number', 'hires.site_id', \DB::raw('MAX(end) AS end'))
->orderBy('hires_days.end', 'asc')
->groupBy('hires.id')
->paginate(10);

如果他们的 hire_days 中至少有一个已经过去,这将返回 hires,而忽略了一些相关的 hire_days 仍然存在的事实 future 。

最佳答案

我认为您需要的是添加到您的查询中:

->having('end', '<', time())

关于php - Laravel `Item` 有很多,只有在过去时才返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36913165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com