38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Services;
|
|
|
|
use App\Enums\LetterStatus;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class LetterRequestRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
if ($this->routeIs('student.*')) {
|
|
return (bool) $this->user()->student;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
if ($this->routeIs('student.*')) {
|
|
return [
|
|
'letter_type' => ['required', 'string', 'max:100'],
|
|
'purpose' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
return [
|
|
'student_id' => ['required', 'integer', Rule::exists('students', 'id')],
|
|
'letter_type' => ['required', 'string', 'max:100'],
|
|
'purpose' => ['nullable', 'string'],
|
|
'status' => ['nullable', Rule::enum(LetterStatus::class)],
|
|
'result' => ['nullable', 'file', 'max:10240', 'mimes:pdf,jpg,jpeg,png,doc,docx'],
|
|
];
|
|
}
|
|
}
|