<?php

namespace App\Modules\HR\Training\Services;

use App\Modules\HR\Training\Models\TrainingSession;
use App\Modules\HR\Training\Repositories\TrainingRepository;
use Illuminate\Validation\ValidationException;

class TrainingService
{
    public function __construct(private readonly TrainingRepository $repository) {}

    public function enroll(TrainingSession $session, array $employeeIds): void
    {
        if ($session->status === 'cancelled') {
            throw ValidationException::withMessages(['session' => __('training.cancelled_session')]);
        }
        $this->repository->enroll((int) $session->tenant_id, (int) $session->id, $employeeIds);
    }
}
