siakad-itm/app/Http/Requests/Admin/Manage/CourseClassRequest.php
Yoga Pangestu 015cbc229b feat: add course and class enrollment management
- Implemented ClassEnrollmentIndex component for managing class enrollments, including adding and removing students.
- Created CourseClassIndex component for managing course classes with CRUD functionality.
- Developed columns for course management in createCourseColumns function.
- Added CourseIndex component for managing courses with CRUD operations.
- Introduced types for class enrollment and course class to enhance type safety.
- Updated routes to include endpoints for managing courses, course classes, and enrollments.
2026-08-21 19:06:05 +07:00

34 lines
989 B
PHP

<?php
namespace App\Http\Requests\Admin\Manage;
use App\Enums\ClassMethod;
use App\Models\Course;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class CourseClassRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
$departmentId = Course::find($this->input('course_id'))?->department_id;
return [
'course_id' => ['required', 'integer', Rule::exists('courses', 'id')],
'lecturer_id' => [
'required',
'integer',
Rule::exists('lecturers', 'id')->where('department_id', $departmentId),
],
'academic_term_id' => ['required', 'integer', Rule::exists('academic_terms', 'id')],
'class_name' => ['nullable', 'string', 'max:50'],
'method' => ['nullable', 'string', Rule::in(array_column(ClassMethod::cases(), 'value'))],
];
}
}