I have a code to use scope function in orm
public function scopeFreeTime($query, $month, $start_time, $end_time){
return $query->whereHas('shifts' ,function ($query) use ($month) {
$query->where('month', $month);
})->with(['shifts' => function ($query) use ($month) {
$query->where('month', $month);
}])->whereDoesntHave('leaves' ,function ($query) use ($start_time, $end_time) {
$query->where('start_time', '<', $end_time);
$query->where('end_time', '>', $start_time);
})->whereDoesntHave('orders' ,function ($query) use ($start_time, $end_time) {
$query->where('start_time', '<', $end_time);
$query->where('end_time', '>', $start_time);
$query->where('is_finished', false);
});
}
My env is php7.1 laravel 5.2
when I use php7.3 run it, I will get the error
count(): Parameter must be an array or an object that implements Countable
I know this is php7.2 feature, but I don’t know how to resolve it in my code.
php7.1 is very old, I want to just upgrade php don’t upgrade laravel.