Hello I have in Product model variable appends
with:
protected $appends = ['finalPrice'];
public function getFinalPriceAttribute()
{
if ($this->discount_type == 1) {
return intval($this->price -= $this->discount);
} elseif ($this->discount_type == 0) {
return intval($this->price * (1 - $this->discount / 100));
}
return $this->price;
}
When I want use this attribute on wherebetween I get error: undifined column finalPrice
:
$_products = Product::active()
->whereBetween('finalPrice', [$whereSum['min'], $whereSum['max']])
->orderBy($orderColumn, $orderBy);
How I can fix this?