Best approach to save "price" field

What is the best approach to save decimal values like price, subtotal, and total in a Laravel migration? In my app, I’m using
$table->decimal('total', 10, 2);

but since I’m using PostgreSQL, it’s not working. I’m also trying to format the values like this:

$set(
    'total',
    Number::format(
        $subtotal,
        maxPrecision: 2
    )
); // The format results in something like 596,490, which isn't working for decimals.


How can I fix this?
Was this page helpful?