<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Mehrab\Service\Models\Service;

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

            $table->foreignId('parent_id')
                ->nullable()
                ->constrained('services','id')
                ->onDelete('SET NULL');

            $table->foreignId('media_id')
                ->nullable()
                ->constrained('media','id')
                ->onDelete('SET NULL');

            $table->string('name','255');
            $table->string('slug','255')->unique();
            $table->string('title','255')->nullable();
            $table->float('priority')->nullable();
            $table->json('description')->nullable();
            $table->bigInteger('days_provide')->default(10);
            $table->enum('status',Service::$status)->default(Service::INACTIVE);
            $table->boolean('is_slider')->default(0);
            $table->boolean('is_discount')->default(0);
            $table->timestamps();
        });
    }

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