<?php

namespace App\Http\Controllers;

use App\Models\Level;
use Illuminate\View\View;

class LevelController extends Controller
{
    public function index(): View
    {
        $levels = Level::active()->orderBy('order')->get();

        return view('levels.index', compact('levels'));
    }

    public function show(string $slug): View
    {
        $level = Level::active()->where('slug', $slug)->firstOrFail();
        $others = Level::active()->where('id', '!=', $level->id)->orderBy('order')->get();

        return view('levels.show', compact('level', 'others'));
    }
}
