<?php

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

/**
 * Venue working days/hours (1.2): either inherit the business default or set
 * custom ones. Drives the visit-booking time limits in the client funnel (2.6).
 * Stored as { use_default, days[], open, close }.
 */
return new class extends Migration {
    public function up(): void
    {
        if (! Schema::hasColumn('bms_venues', 'working_hours')) {
            Schema::table('bms_venues', function (Blueprint $t) {
                $t->json('working_hours')->nullable()->after('description');
            });
        }
    }

    public function down(): void
    {
        if (Schema::hasColumn('bms_venues', 'working_hours')) {
            Schema::table('bms_venues', function (Blueprint $t) {
                $t->dropColumn('working_hours');
            });
        }
    }
};
