<?php

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

class CreateMembersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id');
            $table->unsignedInteger('branch_id')->nullable();
            $table->string('type');
            $table->string('informal_name')->nullable();
            $table->string('formal_name')->nullable();
            $table->string('kvk_number')->nullable();
            $table->string('website')->nullable();
            $table->string('logo')->nullable();
            $table->integer('b_cp')->nullable();
            $table->integer('b_cc')->nullable();
            $table->integer('kg_cp')->nullable();
            $table->integer('kg_cc')->nullable();
            $table->integer('av_cp')->nullable();
            $table->integer('av_cc')->nullable();
            $table->boolean('show_on_website')->default(false);
            $table->string('helpdesk_department')->nullable();
            $table->string('helpdesk_contact_person')->nullable();
            $table->string('helpdesk_email')->nullable();
            $table->string('helpdesk_phone')->nullable();
            $table->string('info_department')->nullable();
            $table->string('info_contacteperson')->nullable();
            $table->string('info_email')->nullable();
            $table->string('info_phone')->nullable();
            $table->string('info_address')->nullable();
            $table->string('info_housenumber')->nullable();
            $table->string('info_postal')->nullable();
            $table->string('info_city')->nullable();
            $table->string('info_link')->nullable();
            $table->string('more_info_link')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::table('members', function (Blueprint $table) {
            $table->foreign('user_id')->references('id')->on('users');
            $table->foreign('branch_id')->references('id')->on('branches');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('members', function (Blueprint $table) {
            $table->dropForeign('members_user_id_foreign');
            $table->dropForeign('members_branch_id_foreign');
        });

        Schema::dropIfExists('members');
    }
}
