<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Plan;
use Illuminate\Http\Request;

class PlanController extends Controller
{
    /**
     * List all active plans.
     */
    public function index()
    {
        $plans = Plan::active()
            ->orderBy('price')
            ->get();

        return response()->json(['plans' => $plans]);
    }

    /**
     * Get a single plan by slug.
     */
    public function show(string $slug)
    {
        $plan = Plan::where('slug', $slug)
            ->where('is_active', true)
            ->firstOrFail();

        return response()->json(['plan' => $plan]);
    }
}
