<?php

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

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

            $table->foreignId('user_id')->nullable()->constrained('users');
            $table->foreignId('category_id')->nullable()->constrained('categories');
            $table->foreignId('sub_category_id')->nullable()->constrained('categories');
            
            $table->string('name');
            $table->text('excerpt')->nullable();
            $table->text('desc')->nullable();
            $table->decimal('price', 15, 2)->nullable();
            $table->string('duration')->nullable(); // مدت زمان خدمت
            $table->string('type')->nullable();
            
            $table->foreignId('province_id')->nullable()->constrained('provinces');
            $table->foreignId('county_id')->nullable()->constrained('counties');
            $table->text('address')->nullable();
            
            $table->json('gallery')->nullable();
            $table->string('image')->nullable();
            
            $table->enum('status', ['active', 'inactive', 'pending'])->default('active');
            $table->boolean('is_active')->default(true);
            
            $table->integer('view_count')->default(0);

            $table->foreignId('created_by')->constrained('users');
            $table->foreignId('updated_by')->nullable()->constrained('users');
            $table->softDeletes();
            $table->timestamps();
        });
    }

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