<?php

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

class AddColumnAndCreateDataPropertyRoomViewTypeTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('property_room_view_type', function (Blueprint $table) {
            $table->string('language_key',100)->after('name')->nullable();
        });

        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        DB::table('property_room_view_type')->truncate();
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');

        DB::table('property_room_view_type')->insert(
            [
                [
                    'name' => 'Park',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'Pool ',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'River',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'Sea ',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'Street',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'Valley',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ],
                [
                    'name' => 'Monument',
                    'status' => 1,
                    'created_by' => 1,
                    'updated_by' => 1,
                    'created_at' => 1,
                    'updated_at' => 1,
                ]
            ]

        );
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('property_room_view_type', function (Blueprint $table) {
            $table->dropColumn('language_key');
        });

        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
        DB::table('property_room_view_type')->truncate();
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');

    }
}
