Laravel Schema Builder not setting the right digits amount on Double datatype

4.9k Views Asked by At

So, I need to save amounts that go up to 999,999,999,999.99, and in the documentation of the Schema Builder of Laravel says that I can set up up to 15 digits and 8 decimals, but this is not working (https://laravel.com/docs/5.2/migrations#writing-migrations)

In Column Types says:

$table->double('column', 15, 8); DOUBLE equivalent with precision, 15 digits in total and 8 after the decimal point.

The line of code in my migration is the following:

$table->double('m1',12,2)->default(0)->nullable();

Any ideas? Thank you.

1

There are 1 best solutions below

0
On

try use:

 $table->decimal('m1',12,2)->default(0)->nullable();

if your values only positive... then use:

$table->decimal('m1',12,2)->unsigned()->default(0)->nullable();

works to me!