<?php

use App\Models\UserManagement\Admin;
use App\Models\UserManagement\Customer;
use App\Models\UserManagement\User;
use App\Models\UserManagement\UserType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(){

        $models = [Customer::class , Admin::class];

        foreach ($models as $model) {
            if (!Schema::hasTable((new $model)->getTable())){
                Schema::create((new $model)->getTable(), function (Blueprint $table) {
                    $table->id();
                    $table->string('first_name');
                    $table->string('last_name')->nullable();
                    $table->string('username')->unique()->nullable();
                    $table->string('email')->unique()->nullable();
                    $table->string('phone')->unique()->nullable();
                    $table->string('password')->nullable();
                    $table->boolean('active')->default(true);
                    $table->boolean('receive_email')->default(true);
                    $table->timestamp('email_verified_at')->nullable();
                    $table->rememberToken();
                    $table->timestamps();
                    $table->softDeletes();
                });
            }
        }



    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(){
        Schema::dropIfExists((new User)->getTable());
        Schema::dropIfExists((new Admin)->getTable());
    }
};
