<?php

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

class CreateDriversTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('drivers', function (Blueprint $table) {
            $table->id(); // Primary key
            
            // Foreign key reference to the users table
            $table->string('user_id'); // Make user_id VARCHAR type
            
            // Defining foreign key relationship
            $table->foreign('user_id') // Referencing user_id in the users table
                ->references('user_id')
                ->on('users')
                ->onDelete('cascade');

            // Driving license details
            $table->string('driving_license_number');
            $table->date('driving_license_expiry');
            $table->string('driving_license_front')->nullable(); // Path to front image
            $table->string('driving_license_back')->nullable();  // Path to back image

            // PAN card details
            $table->string('pan_card_number');
            $table->string('pan_card_photo')->nullable(); // Path to PAN card image

            // Aadhar card details
            $table->string('aadhar_card_number');
            $table->string('aadhar_card_front')->nullable(); // Path to front image
            $table->string('aadhar_card_back')->nullable();  // Path to back image

            // Bike details
            $table->string('bike_brand');
            $table->string('bike_model');
            $table->year('bike_year');
            $table->string('bike_registration_plate');
            $table->string('vehicle_number');
            $table->string('chassis_number');

            // Insurance details
            $table->string('insurance_number');
            $table->date('insurance_expiry');

            // Vehicle inspection details
            $table->date('vehicle_inspection_date');
            $table->date('inspection_expiry_date');

            // Vehicle images
            $table->string('vehicle_picture_front')->nullable();
            $table->string('vehicle_picture_back')->nullable();
            $table->string('vehicle_picture_left')->nullable();
            $table->string('vehicle_picture_right')->nullable();

            // Vehicle document images
            $table->string('vehicle_document_1')->nullable();
            $table->string('vehicle_document_2')->nullable();
            $table->string('vehicle_document_3')->nullable();
            $table->string('vehicle_document_4')->nullable();

            // Timestamps for created_at and updated_at
            $table->timestamps();
        });
    }

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