<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::create('store_locations', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('address');
            $table->string('city');
            $table->string('state');
            $table->string('country');
            $table->string('zipcode');
            $table->string('phone');
            $table->string('email')->nullable();
            $table->text('operating_hours');
            $table->decimal('latitude', 10, 8)->nullable();
            $table->decimal('longitude', 11, 8)->nullable();
            $table->boolean('is_active')->default(true);
            $table->boolean('has_pickup')->default(true);
            $table->boolean('has_delivery')->default(true);
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::create('store_inventory', function (Blueprint $table) {
            $table->id();
            $table->foreignId('store_id')->constrained('store_locations');
            $table->foreignId('product_id')->constrained();
            $table->integer('quantity');
            $table->integer('low_stock_threshold');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('store_inventory');
        Schema::dropIfExists('store_locations');
    }
};