I have written an Online Store with Laravel 5.8 and in this project I want to define amount
column at user_transactions
table with Decimal 19.2 data type.
So I opened up phpmyadmin
and changed the data type to decimal
.
Now I need to know how to define Decimal(19.2) in both phpmyadmin
and Laravel Migration.
I already know how to use Decimal data types in Laravel by saying:
$table->decimal('amount');
But where does the 19.2
define?
Advertisement
Answer
i believe you are talking about precision and scale here. you can declare the column with
$table->decimal('amount', 19, 2);
from the docs this is
DECIMAL equivalent column with a precision (total digits) and scale (decimal digits).
as for the phpMyAdmin, choose type DECIMAL
and Length/Values 19,2
. this will do the same. but don’t use phpMyAdmin directly. use migration to modify/add columns to the table.