F
Filament9mo ago
dasK_

Storing and Retrieving Price

I have just changed all of my tables and functions to use cents instead of dollar values, for the most part now it's working as expected, in Filament however, I'm able to divideBy: 100 in the TextColumn But I'm not able to do the same in the form when it displays the price? I have a function in my product model that converts the dollar value to cents so I can enter in the $4.50 or whatever in the form and it's handled, I've tried to play around with hydration but couldn't work it out.
2 Replies
dasK_
dasK_OP9mo ago
thanks for the link, I feel as though it's basically the same thing as what I'm doing?
public function getRetailPriceAttribute($value)
{
return $value / 100;
}

public function setRetailPriceAttribute($value)
{
$this->attributes['retailPrice'] = $value * 100;
}
public function getRetailPriceAttribute($value)
{
return $value / 100;
}

public function setRetailPriceAttribute($value)
{
$this->attributes['retailPrice'] = $value * 100;
}
I don't want to get the attribute as a decimal value, I just want filament to do that
Want results from more Discord servers?
Add your server