<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\WorkoutPlan;
use Illuminate\View\View;

class WorkoutPlanIndexController extends Controller
{
    public function index(): View
    {
        $this->authorize('viewAny', WorkoutPlan::class);

        $plans = WorkoutPlan::query()
            ->with(['athlete.user', 'coach.user'])
            ->latest()
            ->paginate(20);

        return view('admin.workout-plans.index', compact('plans'));
    }

    public function show(WorkoutPlan $plan): View
    {
        $this->authorize('view', $plan);

        $plan->load(['athlete.user', 'coach.user', 'goal', 'sessions.exercises.exercise.mainMuscle']);

        return view('admin.workout-plans.show', compact('plan'));
    }
}
