<?php

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

class CreateAdsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ads', function (Blueprint $table) {
            $table->id();
            $table->enum('status' , [0,1,2])->default(0);
            $table->bigInteger('area_id')->unsigned();
            $table->bigInteger('service_id')->unsigned();
            $table->bigInteger('type_id')->unsigned();
            $table->bigInteger('user_id')->unsigned();
            $table->bigInteger('marketed_id')->unsigned()->nullable();
            $table->double('price')->default(0);
            $table->string('lat')->nullable();
            $table->string('long')->nullable();
            $table->enum('bank', [0, 1])->default(0);
            $table->string('coverage')->nullable();
            $table->integer('room')->default(0);
            $table->integer('hall')->default(0);
            $table->integer('bathroom')->default(0);
            $table->string('interface');
            $table->enum('car_entrance', [0, 1])->default(0);
            $table->enum('driver_room', [0, 1])->default(0);
            $table->enum('maid_room', [0, 1])->default(0);
            $table->enum('swimming_pool', [0, 1])->default(0);
            $table->enum('kitchen', [0, 1])->default(0);
            $table->enum('inner_staircase', [0, 1])->default(0);
            $table->enum('appendix', [0, 1])->default(0);
            $table->enum('furnished', [0, 1])->default(0);
            $table->integer('property_age');
            $table->integer('street_view');
            $table->integer('determine_area');
            $table->string('office_name');
            $table->string('office_num');
            $table->string('office_reach');
            $table->text('des');
            $table->enum('featured', [0, 1])->default(0);
            $table->enum('administration', [0, 1])->default(0);
            $table->enum('featured_ad', [0, 1])->default(0);
            $table->integer('count_view')->default(0);


            $table->timestamps();
            $table->foreign('area_id')->references('id')->on('areas')->onDelete('cascade');
            $table->foreign('service_id')->references('id')->on('services')->onDelete('cascade');
            $table->foreign('type_id')->references('id')->on('types')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('marketed_id')->references('id')->on('users')->onDelete('cascade');
        });
    }

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