Some checks failed
tests / ci (pull_request) Has been cancelled
- Implemented filter dialogs in the following pages: - Academic Classes Assignments - Course Registrations - Materials - Announcements - Feedback - Tuition Invoices - Course Classes - Courses - Academic Terms - Academic Advising Logs - Letter Requests - Administrators - Lecturers - Students - Updated the useServerTable hook to support filter parameters. - Enhanced the UI with filter options for better data management and retrieval.
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use App\Enums\ClassMethod;
|
|
use App\Enums\Gender;
|
|
use App\Enums\Semester;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class PaginatedRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'per_page' => ['nullable', 'integer', 'in:25,50,100,999999'],
|
|
'search' => ['nullable', 'string', 'max:255'],
|
|
'sort' => ['nullable', 'string'],
|
|
'direction' => ['nullable', 'string', 'in:asc,desc'],
|
|
'highlight' => ['nullable', 'integer'],
|
|
'gender' => ['nullable', 'string', Rule::in(Gender::values())],
|
|
'department_id' => ['nullable', 'integer'],
|
|
'status' => ['nullable', 'string'],
|
|
'semester' => ['nullable', 'string', Rule::in(Semester::values())],
|
|
'is_active' => ['nullable', Rule::in(['true', 'false'])],
|
|
'academic_term_id' => ['nullable', 'integer'],
|
|
'method' => ['nullable', 'string', Rule::in(ClassMethod::values())],
|
|
'course_class_id' => ['nullable', 'integer'],
|
|
'lecturer_id' => ['nullable', 'integer'],
|
|
'type' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
public function validatedWithDefaults(): array
|
|
{
|
|
$validated = $this->validated();
|
|
|
|
return [
|
|
'perPage' => $validated['per_page'] ?? 25,
|
|
'search' => $validated['search'] ?? '',
|
|
'sort' => $validated['sort'] ?? 'created_at',
|
|
'direction' => $validated['direction'] ?? 'desc',
|
|
];
|
|
}
|
|
}
|