user()?->hasRole('Admin') === true; } protected function prepareForValidation(): void { $this->merge([ 'ic_number' => blank($this->input('ic_number')) ? null : preg_replace('/\D+/', '', (string) $this->input('ic_number')), 'saluran_mengundi_id' => blank($this->input('saluran_mengundi_id')) ? null : $this->input('saluran_mengundi_id'), ]); } /** * @return array */ public function rules(): array { return [ 'type' => ['required', Rule::in(['police', 'kkm', 'jkm'])], 'election_id' => ['required', 'integer', 'exists:elections,id'], 'pusat_mengundi_id' => ['required', 'integer', 'exists:pusat_mengundis,id'], 'saluran_mengundi_id' => ['nullable', 'integer', 'exists:saluran_mengundis,id'], 'name' => ['required', 'string', 'max:255'], 'ic_number' => ['nullable', 'digits:12'], 'phone_number' => ['nullable', 'string', 'max:30'], 'rank' => ['nullable', 'string', 'max:255'], 'station' => ['nullable', 'string', 'max:255'], 'agency' => ['nullable', 'string', 'max:255'], 'notes' => ['nullable', 'string', 'max:2000'], 'note' => ['nullable', 'string', 'max:2000'], ]; } }