Some checks failed
tests / ci (pull_request) Has been cancelled
- Created sub-namespaces under Admin\Manage for Course, Academic, Announcement, Finance, and Service. - Added new FormRequest classes for handling validation in each sub-namespace. - Implemented Service classes for managing business logic related to each resource. - Updated routes to reflect the new sub-namespace structure. - Enhanced code organization and maintainability by grouping related functionalities.
30 lines
781 B
PHP
30 lines
781 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Manage\Course;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ClassEnrollmentRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$courseClass = $this->route('course_class');
|
|
$departmentId = $courseClass->course->department_id;
|
|
|
|
return [
|
|
'student_ids' => ['required', 'array', 'min:1'],
|
|
'student_ids.*' => [
|
|
'integer',
|
|
Rule::exists('students', 'id')->where('department_id', $departmentId),
|
|
Rule::unique('class_enrollments', 'student_id')->where('course_class_id', $courseClass->id),
|
|
],
|
|
];
|
|
}
|
|
}
|