<?php

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

class CreatePropertyContactTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_contact', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('property_id')->unsigned();
            $table->string('phone',50)->nullable();
            $table->string('phone_code',10)->nullable();
            $table->string('mobile',50)->nullable();
            $table->string('mobile_code',10)->nullable();
            $table->string('fax',50)->nullable();
            $table->string('fax_code',10)->nullable();
            $table->string('email',100)->nullable();
            $table->integer('destination_id')->unsigned();
            $table->string('web',100)->nullable();
            $table->string('zip_code',20)->nullable();
            $table->string('address',200)->nullable();
            $table->double('latitude',10,6)->nullable();
            $table->double('longitude',10,6)->nullable();
            $table->tinyInteger('status')->default(1);
            $table->unsignedInteger('created_by');
            $table->unsignedInteger('updated_by');
            $table->integer('created_at');
            $table->integer('updated_at');
        });

        Schema::table('property_contact',function (Blueprint $table) {
            $table->foreign('property_id')->references('id')->on('property');
            $table->foreign('created_by')->references('id')->on('user');
            $table->foreign('updated_by')->references('id')->on('user');
            $table->unique(['property_id'],'pc_unique');
        });
    }

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