user()?->hasRole('Admin') === true; } /** * @return array */ public function rules(): array { $bahagian = $this->route('bahagianPilihanraya'); return [ 'election_id' => ['required', 'exists:elections,id'], 'code' => [ 'required', 'string', 'max:50', Rule::unique('bahagian_pilihanrayas', 'code') ->where('election_id', $this->input('election_id')) ->ignore($bahagian instanceof BahagianPilihanraya ? $bahagian->id : null), ], 'name' => ['required', 'string', 'max:255'], ]; } }