<?php

use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransportType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTransportArrangementsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('transport_arrangements', function (Blueprint $table) {
            $table->id();
            $table->morphs('owner');
            $table->integer('type')->default(TransportType::SEA);

            $table->string('courier')->nullable();
            $table->string('tracking_number')->nullable();

            $table->timestamp('dispatch_date')->nullable();
            $table->timestamp('drop_date')->nullable();

            $table->integer('status')->default(ApprovalStatus::PENDING_VERIFICATION);
            $table->softDeletes();
            $table->timestamps();
        });

        Schema::table('transport_arrangements', function (Blueprint $table) {
            $table->string('owner_type', 191)->change();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('transport_arrangements');
    }
}
