Laravel - Number with 4 decimals

eloquent, laravel, laravel-5, sql

Solution

Use the following;

$table->decimal('foo', 5, 4);

The first parameter is the total number of numbers, the second parameter is the "decimal precision".

Problem

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

Original source