<?php

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

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('users'); // Drop the existing users table

        Schema::create('users', function (Blueprint $table) {
            $table->id(); // Auto-incrementing ID
            $table->string('name');
            $table->string('phone_number')->unique();
            $table->string('email')->nullable();
            $table->string('avatar')->nullable();
            $table->string('otp')->nullable();
            $table->string('password')->nullable();
            $table->enum('role', ['user', 'admin', 'vendor', 'driver'])->default('user');
            $table->string('referral_code')->nullable();
            $table->string('user_id')->unique(); // Custom ID based on role
            $table->string('remember_token')->nullable();
            $table->timestamp('otp_expiration')->nullable();
            $table->timestamps();
        });
    }

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