【发布时间】:2021-06-24 09:58:52
【问题描述】:
我是否遗漏了一些东西,但这不起作用?我有模型属性 getEntryEndingAttribute
public function getEntryEndingAttribute ()
{
if($this->whereBetween('ending', [now(), now()->addDays(1)])) {
return TRUE;
}
return FALSE;
}
我从调试中得到的结果是
select count(*) as aggregate from `entries` where `ending` >= '2021-03-27 23:08:25'
当我从控制器做同样的事情时
$entries = Entry::whereBetween('ending', [now(), now()->addDays(1)])->orderBy('ending', 'ASC')->get();
调试结果正确
select count(*) as aggregate from `entries` where `ending` between '2021-03-27 23:10:52' and '2021-03-28 23:10:52'
有什么想法吗?
谢谢。
【问题讨论】: