<?php

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

class CreateMensagensChatsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('mensagenschats', function (Blueprint $table) {
            $table->id();
            $table->text('mensagem')->nullable();
            $table->enum('tipomensagem',['normal','chamadaaudio','chamadavideo','ficheiro'])->default('normal');
            $table->enum('estadomensagem',['lido','naolido'])->default('naolido');
            $table->enum('estado',['lido','naolido'])->default('naolido');
            $table->text('ficheiro')->nullable();
            $table->string('nomeoriginal')->nullable();
            $table->string('tamanhoarquivo')->nullable();
            $table->foreignId('user_from');
            $table->foreignId('user_to')->nullable();
            $table->foreign('user_from')->references('id')->on('users')->onDelete('cascade');
            $table->foreign('user_to')->references('id')->on('users')->onDelete('cascade');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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