<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('job_info_types', function (Blueprint $table) {
            $table->id();

            $table->string('name')->unique()->index(); // html input type

            $table->timestamps();
        });

        $this->seed();
    }

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

    public function seed(): void
    {
        $jobInfosTypes = [
            [
                "id" => 1,
                "name" => "text",
            ],
            [
                "id" => 2,
                "name" => "email",
            ],
            [
                "id" => 3,
                "name" => "password",
            ],
            [
                "id" => 4,
                "name" => "url",
            ],
        ];

        foreach ($jobInfosTypes as $jobInfoType) {
            \App\Models\JobInfoType::forceCreate($jobInfoType);
        }
    }
};
