Wanting to ask if its possible to use existing attributes in a model and use them for counts.
My repository is based off a Lead model and this model contains 2 attributes i want to count.
/**
* Checks to see if the lead is cold (no action for a few days)
*
* @return bool
*/
public function getColdLeadAttribute():bool
{
return $this->lead_last_action >= 2 && ($this->status == Status::INITIATION->value || $this->status == Status::QUALIFICATION->value || $this->status == Status::DEAL_BUILDING->value);
}
/**
* Checks to see if the lead is warm (close to closing a deal)
*
* @return bool
*/
public function getWarmLeadAttribute():bool
{
if($this->offerApprovedApprovals()->exists()){
return $this->status == Status::DEAL_BUILDING->value && $this->offer_approved_approvals_count;
}else {
return false;
}
}