我想计算updated_at 比created_at 早2 小时的记录。
Code
$teLang = $kentekens->where('updated_at', '>', 'created_at'->subHours(2));
不幸的是,这不起作用,因为 subHours(2) 适用于碳,但希望您明白这一点。
View
<h1>{{ $teLang->count() }}</h1>
控制器
public function create() {
$kentekens = Kenteken::latest()
->where('created_at', '>=', Carbon::today())
->get();
$teLang = $kentekens->where('updated_at', '>', 'created_at'->subHours(2));
return view('layouts.dashboard', compact('kentekens', 'teLang'));
}
有人知道怎么做吗?
$kentekens->whereRaw('`updated_at` > DATE_ADD(`created_at`, INTERVAL 2 HOUR)');
SQL:
select `id` from `tablename` where `updated_at` > DATE_ADD(`created_at`, INTERVAL 2 HOUR)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)