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'), '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 */ public function rules(): array { return [ 'election_id' => ['required', 'integer', 'exists:elections,id'], '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'], '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'], ]; } }