I want to store 1 number with 4 decimals, in my database.
If i use float i can add only 2 decimals
$table->float('sell');
If I try with decimal i get an error
$table->decimal('sell', 1, 4);
The first number must be greater than or equal to the second number.
SQLSTATE[42000]: Syntax error or access violation: 1427 For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '
sell'). (SQL: create table customers
(id
int unsigned not null auto_increment primary key, sell
decimal(1, 4) not null,created_at
timestamp null, updated_at
timestamp null) default character set utf8 collate utf8_unicode_ci)
Any help?
Thanks
Use the following;
$table->decimal('foo', 5, 4);
The first parameter is the total number of numbers, the second parameter is the "decimal precision".
In your schema file.
$table->decimal('your_field_name', 13, 4);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With