<?php

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

class CreateFuncionarioClientesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
          Schema::create('funcionarioclientes', function (Blueprint $table) {
            $table->id();
            $table->string('numeroFuncionariocliente')->unique();
            $table->foreignId('user_id');
            $table->foreignId('categoria_id');
            $table->foreignId('cliente_id');
            $table->foreign('cliente_id')->references('id')->on('clientes')->onDelete('cascade'); //empresa na qual pertence
            $table->foreign('categoria_id')->references('id')->on('categoriaclientes')->onDelete('cascade');
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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