<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddProductFieldsToEstimates extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('estimates', function (Blueprint $table) {
            // Fields to be added
            $table->bigIncrements('id');
            $table->string('prefix')->nullable()->comment("estimate number prefix");
            $table->bigInteger('estimate_number')->nullable()->comment("estimate number without prefix");
            $table->text('estimate_owner_id')->comment('Select the name of the user to whom the estimate is assigned'); // Select the name of the user to whom the estimate is assigned.
            $table->text('status')->nullable();
            // Products related fields
            $table->text('selected_products')->nullable()->comment('store as json');
            $table->enum('discount_type_selected',['before', 'after'])->default('before');
            $table->string('discount_value')->nullable()->comment('discount amount in number');
            $table->string('total_tax')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('estimates', function (Blueprint $table) {
            $table->dropColumn('id');
            $table->dropColumn('prefix');
            $table->dropColumn('estimate_number');
            $table->dropColumn('estimate_owner_id');
            $table->dropColumn('status');
            $table->dropColumn('selected_products');
            $table->dropColumn('discount_type_selected');
            $table->dropColumn('discount_value');
            $table->dropColumn('total_tax');
        });
    }
}
