38 lines
1.3 KiB
PHP
38 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Management;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateStaffAssignmentRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->hasRole('Admin') === true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'saluran_mengundi_id' => blank($this->input('saluran_mengundi_id')) ? null : $this->input('saluran_mengundi_id'),
|
|
'reports_to_assignment_id' => blank($this->input('reports_to_assignment_id')) ? null : $this->input('reports_to_assignment_id'),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'position_id' => ['required', 'integer', 'exists:positions,id'],
|
|
'pusat_mengundi_id' => ['required', 'integer', 'exists:pusat_mengundis,id'],
|
|
'saluran_mengundi_id' => ['nullable', 'integer', 'exists:saluran_mengundis,id'],
|
|
'reports_to_assignment_id' => ['nullable', 'integer', 'exists:staff_assignments,id'],
|
|
'status' => ['required', Rule::in(['active', 'inactive', 'replaced', 'cancelled'])],
|
|
'note' => ['nullable', 'string', 'max:2000'],
|
|
];
|
|
}
|
|
}
|