first
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin\Management;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateManagedApplicationRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user()?->hasRole('Admin') === true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$this->merge([
|
||||
'ic_number' => preg_replace('/\D+/', '', (string) $this->input('ic_number')),
|
||||
'phone_number' => trim((string) $this->input('phone_number')),
|
||||
'email' => blank($this->input('email')) ? null : strtolower(trim((string) $this->input('email'))),
|
||||
'selected_ktm_assignment_id' => blank($this->input('selected_ktm_assignment_id')) ? null : $this->input('selected_ktm_assignment_id'),
|
||||
'approved_position_id' => blank($this->input('approved_position_id')) ? null : $this->input('approved_position_id'),
|
||||
'bank_name' => blank($this->input('bank_name')) ? null : trim((string) $this->input('bank_name')),
|
||||
'bank_account_number' => blank($this->input('bank_account_number')) ? null : preg_replace('/\D+/', '', (string) $this->input('bank_account_number')),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'pusat_mengundi_id' => ['required', 'integer', 'exists:pusat_mengundis,id'],
|
||||
'selected_ktm_assignment_id' => ['nullable', 'integer', 'exists:staff_assignments,id'],
|
||||
'requested_position_id' => ['required', 'integer', 'exists:positions,id'],
|
||||
'approved_position_id' => ['nullable', 'integer', 'exists:positions,id'],
|
||||
'status' => ['required', Rule::in(['draft', 'submitted', 'under_ppm_review', 'approved', 'rejected', 'assigned', 'cancelled'])],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'ic_number' => ['required', 'digits:12'],
|
||||
'phone_number' => ['required', 'string', 'max:30'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'address' => ['nullable', 'string', 'max:2000'],
|
||||
'bank_name' => ['nullable', 'string', 'max:255'],
|
||||
'bank_account_number' => ['nullable', 'string', 'max:50'],
|
||||
'note' => ['nullable', 'string', 'max:2000'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user