I'm trying to include an additional dateTime field to my products table with the name "expiry_date". I will be using this date in the future to check for product's expiry date. I don't know the best column type to assign for this field, also, I'm thinking of using Carbon but I don't really know the best approach to implement such.
Products Migration
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('prod_name');
$table->string('barcode');
$table->string('model')->nullable();
$table->bigInteger('quantity');
$table->decimal('amount', 8, 2);
$table->decimal('total_amount', 8, 8);
$table->integer('manufacturer_id');
$table->integer('batch_id');
$table->foreign('manufacturer_id')->references('id')->on('manufacturers')
->onDelete('cascade')->onUpdate('cascade');
$table->foreign('batch_id')->references('id')->on('batches')
->onDelete('cascade')->onUpdate('cascade');
$table->dateTime('expiry_date');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}