HI there,
This could just be a Friday brain drain but for the life of me i can't workout/remember how to filter a dataset using a function on the model. I have a Runner data model and i wish to return all runners thats easy
$runners = Runner::get();
return $runners
but the next stage is to only bring back runners that are overdue at their checkpoint so i have a function on the model.
public function RunnerOverdue() {
$distance = self::NextCP();
$thetime = strtotime(self::TheLKPtime());
if($distance and self::Pace() > 0){
$nexttime = (($distance / self::Pace()) * 60 * 60);
$current = time();
$next = $thetime + $nexttime;
if($current > $next){
$overDue = true;
} else {
$overDue = false;
}
return $overDue;
}
}
So what i want to do is only return the Runners that have a RunnerOverdue = true
I did this before about 12-18 months ago and it worked, now it doesnt, the old code was
function getOverdue() {
$runners = Runner::get()->filter('RunnerOverdue()' > 0);
return $runners;
}
any help or pointers please?
Mick