<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('plans', function (Blueprint $table) {
            $table->id();
            $table->string('name');             // "Daily Essentials", "Weekly Family"
            $table->string('slug')->unique();
            $table->text('description');
            $table->enum('frequency', ['daily', 'weekly']);
            $table->integer('meals_per_delivery');  // how many meals per drop-off
            $table->integer('deliveries_per_week'); // 7 for daily, 1-3 for weekly
            $table->decimal('price', 8, 2);         // recurring price
            $table->decimal('price_per_meal', 8, 2);
            $table->string('stripe_price_id')->nullable();
            $table->boolean('is_active')->default(true);
            $table->boolean('is_featured')->default(false);
            $table->json('features')->nullable();   // ["Free delivery", "Cancel anytime"]
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('plans');
    }
};
