<?php

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

class CreateNotificationsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('notifications', function (Blueprint $table) {
            $table->id();

            $table->string('url')->nullable();
            $table->string('type')->nullable();
            $table->string('title_ar')->nullable();
            $table->string('title_en')->nullable();
            $table->foreignId('user_id')->nullable()->references('id')->on('users')->cascadeOnDelete(); // المرسل
            $table->foreignId('from_user_id')->references('id')->on('users')->cascadeOnDelete(); // المرسل اليه
            $table->integer('modal_id')->nullable();
            $table->text('message_ar');
            $table->text('message_en');
            $table->string('photo')->nullable();
            $table->integer('read')->default(0);

            $table->timestamps();
        });
    }

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