Some checks failed
tests / ci (pull_request) Has been cancelled
- Implemented academic advising logs functionality with create, edit, and delete capabilities. - Created UI components for displaying academic advising logs in a data table format. - Added letter requests management with similar CRUD operations and UI components. - Refactored routes to organize academic classes, announcements, finances, and services under appropriate namespaces.
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\AcademicClasses;
|
|
|
|
use App\Enums\RegistrationStatus;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class CourseRegistrationRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$registration = $this->route('course_registration');
|
|
|
|
return [
|
|
'student_id' => ['required', 'integer', Rule::exists('students', 'id')],
|
|
'academic_term_id' => ['required', 'integer', Rule::exists('academic_terms', 'id')],
|
|
'course_class_id' => [
|
|
'required',
|
|
'integer',
|
|
Rule::exists('course_classes', 'id'),
|
|
Rule::unique('course_registrations')
|
|
->where('student_id', $this->input('student_id'))
|
|
->ignore($registration?->id),
|
|
],
|
|
'status' => ['nullable', 'string', Rule::in(RegistrationStatus::values())],
|
|
'approved_by' => ['nullable', 'integer', Rule::exists('lecturers', 'id')],
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'course_class_id' => 'kelas mata kuliah',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'course_class_id.unique' => 'Mahasiswa ini sudah terdaftar pada kelas mata kuliah tersebut.',
|
|
];
|
|
}
|
|
}
|