Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Pawooo's avatar

Trouble fetching decimals in Laravel 11 Filament V3

This is probably (?) an issue I missed after upgrading to Laravel 11, but I'm getting this error on trying to fetch (not save) decimal data from DB in Laravel 11 Filament V3:

Brick\Math\BigDecimal::toScale(): Argument #1 ($scale) must be of type int, string given, called in /app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 1432

Triggered by

$this->form->fill(auth()->user()->companies->find($companyID)->relationship->attributesToArray());

I already checked the documentation (https://laravel.com/docs/11.x/upgrade#floating-point-types) and updated my migration (https://laravel.com/docs/11.x/migrations#column-method-decimal):

$table->decimal('from', total: 4, places: 3)->nullable();
$table->decimal('to', total: 4, places: 3)->nullable();

Model is unchanged but I don't see anything wrong with it

    protected $casts = [ 
        'from' => 'decimal:4,3',
        'to' => 'decimal:4,3',

TablePlus says columnType is decimal (4,3), so there's absolutely no way I'm passing a string here. It used to work just fine (populating forms with data)...

Any help would be much appreciated!

0 likes
1 reply
Pawooo's avatar
 protected $casts = [ 
        'from' => 'float',
        'to' => 'float',

This worked, but I don't understand why would there be a decimal type (https://laravel.com/docs/11.x/eloquent-mutators) if it ends up saving a string, what am I missing?

4 years ago someone said "PHP doesn't have a decimal type" but I don't understand why make one in the first place and why it worked before?

Also now it retrieves "2.000" as "2." and that's not pretty at all.

Please or to participate in this conversation.