<?php

namespace App\Http\Controllers\Front;

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

class PlatformController extends Controller
{
    public function index(Request $request): View
    {
        return view('platform.index');
    }

    public function plans(Request $request): View
    {
        // 对外展示口径：仅展示“已发布 + 启用中”的套餐，避免未准备好的套餐被外部看到。
        $plans = Plan::query()
            ->where('status', 'active')
            ->whereNotNull('published_at')
            ->orderBy('sort')
            ->orderByDesc('id')
            ->get();

        return view('platform.plans', [
            'plans' => $plans,
        ]);
    }
}
