<?php

namespace App\Http\Controllers\Teacher;

use App\Http\Controllers\Admin\PageController;
use App\Http\Controllers\Teacher\Concerns\ResolvesTeacherScope;
use App\Models\SchoolClass;
use Illuminate\View\View;

class ClassController extends PageController
{
    use ResolvesTeacherScope;

    public function index(): View
    {
        $classes = $this->scope()->classesQuery()
            ->with(['classTeacher', 'students'])
            ->withCount('students')
            ->orderBy('name')
            ->get();

        return $this->page('teacher.classes.index', [
            'crumbTitle' => 'My Classes',
            'crumbSub' => 'Assigned classes & students',
            'classes' => $classes,
        ]);
    }
}
