34 lines
961 B
PHP
34 lines
961 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Classes;
|
|
|
|
use App\Http\Requests\ApiFormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class ClassSectionUpdateRequest extends ApiFormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null || auth()->user() !== null;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$section = $this->route('classSection');
|
|
$sectionId = is_object($section) ? $section->id : $section;
|
|
|
|
return [
|
|
'class_id' => ['sometimes', 'integer', 'min:1'],
|
|
'class_section_id' => [
|
|
'sometimes',
|
|
'integer',
|
|
'min:1',
|
|
Rule::unique('classSection', 'class_section_id')->ignore($sectionId),
|
|
],
|
|
'class_section_name' => ['sometimes', 'string', 'max:100'],
|
|
'semester' => ['sometimes', 'string', 'max:255'],
|
|
'school_year' => ['sometimes', 'string', 'max:9'],
|
|
];
|
|
}
|
|
}
|