File manager - Edit - /var/www/html/spdc/api/app/Http/Requests/DepartmentRequest.php
Back
<?php namespace App\Http\Requests; use App\Enums\ScaleType; use App\Rules\BooleanInput; use App\Rules\ValidEnumOption; use App\Enums\WarningScaleType; use Illuminate\Foundation\Http\FormRequest; class DepartmentRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array<string, mixed> */ public function rules() { $rules = [ 'name' => ['required', 'unique:departments,name'], 'acronym' => ['required', 'unique:departments,acronym'], 'scale_type' => ['required', new ValidEnumOption(ScaleType::cases())], 'warning_scale_type' => ['required', new ValidEnumOption(WarningScaleType::cases())], 'enable' => ['nullable', new BooleanInput], ]; if ($this->route()->getName() === 'department.update') { $rules['name'] = ['required', 'max:255', 'unique:departments,name,'. $this->route('department')->id]; $rules['acronym'] = ['required', 'max:255', 'unique:departments,acronym,'. $this->route('department')->id]; } return $rules; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings