<?php

namespace App\Services\Admin\Manage;

use App\Models\ClassEnrollment;
use App\Models\CourseClass;
use Illuminate\Database\Eloquent\Collection;

class ClassEnrollmentService
{
    public function forClass(CourseClass $courseClass): Collection
    {
        return $courseClass->enrollments()
            ->with(['student.user.profile', 'student.department'])
            ->latest('enrolled_at')
            ->get();
    }

    public function unenroll(ClassEnrollment $enrollment): bool
    {
        return $enrollment->delete();
    }
}
