<?php

use App\Models\SettingManagement\Contact;
use App\Models\UserManagement\Customer;
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(){
        Schema::create((new Contact)->getTable(), function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->string('title');
            $table->longText('message');
            $table->boolean('active')->default(false);

            $table->foreignIdFor(Customer::class,'customer_id')
                ->constrained((new Customer)->getTable(), (new Customer)->getKeyName())
                ->cascadeOnUpdate()->cascadeOnDelete()
                ->comment("[FK]");

            $table->timestamps();
            $table->softDeletes();
        });
    }

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