I have Model with 'scaned_at'
column that I'd like to query like:
$properties = Property::where(function($query) {
$query->where('scaned_at', null)->orWhere('scaned_at', '<', Carbon::now());
});
but it doesn't work and I have no idea why...
You must add ->get();
at the end like:
$properties = Property::where(function($query) {
$query->where('scaned_at', null)->orWhere('scaned_at', '<', Carbon::now());
})->get();
Also, you can do it without function inside:
$properties = Property::where('scaned_at', null)->orWhere('scaned_at', '<', Carbon::now())->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.