Problem with decimal format (EUR) (,)

Hello im using this mask function to format the input field to give me the exact format how i want it.

       TextInput::make('final_price')
                        ->label('Uiteindelijke kosten (excl. btw)')
                        ->numeric()                      
                        ->mask(fn(Forms\Components\TextInput\Mask $mask) => $mask
                        ->patternBlocks([
                            'money' => fn (Mask $mask) => $mask
                                ->numeric()
                                ->thousandsSeparator('.')
                                ->decimalSeparator(',')
                                ->decimalPlaces(2)
                                ->padFractionalZeros()
                                ->normalizeZeros(false),
                        ])
                        ->pattern("€ money")


this is working fine, but the problem is when i save it.
The database has a decimal field.

if i save the field [1st picture]
1500

and the 2nd picture is after i saved it
150.000

I know this has to do with the formatting but i couldnt found a way to fix this, can anyone help me.
image.png
image.png
Solution
 protected function MaximumPriceExcVat(): Attribute
    {
        return Attribute::make(
            get: fn ($value) => price($value,2),
        );
    }
Was this page helpful?