I have a model in which I need to check values and return unhealthy status. I created an Accessor that works and returns true or false as expected.
$task->unhealthy()
Access code
public function getUnhealthyAttribute(){
if ( $this->status_id == 1 ){
return true;
}
if ( $this->items()->overdue()->count() > 0 ) {
return true;
}
return false;
}
Now I have a requirement to get a collection of all the "unhealthy" tasks.
Question . Can I use my Accessor with scope? What would be the right approach?
kayex source
share