<?php

namespace App\Http\Controllers\Athlete;

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

class WorkoutPlanController extends Controller
{
    public function index(): View
    {
        $athlete = auth()->user()->athlete;

        $plans = $athlete->workoutPlans()->with('coach.user')->latest()->get();

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

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

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

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