<?php

use App\Models\Language;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateLanguagesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('languages', function (Blueprint $table) {
            $table->id();
            $table->string('name')->unique();
            $table->string('code')->unique();
            $table->string('icon')->unique()->nullable();
            $table->string('direction', 3)->default('ltr');
            $table->enum('status',[1,0])->default('0')->comment('1 = Active, 0 = In-active');
            $table->timestamps();
        });

        Language::create([
            'name' => 'English',
            'code' => config('app.locale'),
            'icon' => '',
            'direction' => 'ltr',
        ]);
    }

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