In this guide, you will learn how to create the laravel float data type in the migration.
Laraval migration used float()
to create a float type column in the database.
Table of Contents
Laravel float data type migration
As we have discussed that we will using Laravel migration method float()
to create float type column in the database.
The float()
method accepts 3 arguments:
1- Column Name
2- Total digits
3- Digits after decimal
So for example float(‘amount’, 6, 2), here we can save total 6 digits, from which 2 are after decimal
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddNewColumnToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->float('amount', 6, 2);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
Conclusion
Hope in the above article, you have learn how to add and create laravel float data type migration
Write a Reply or Comment