user()?->hasRole('Admin') === true; } /** * @return array */ public function rules(): array { $pusatMengundi = $this->route('pusatMengundi'); $pusatId = $pusatMengundi instanceof PusatMengundi ? $pusatMengundi->id : null; $saluranMengundi = $this->route('saluranMengundi'); $saluranId = $saluranMengundi instanceof SaluranMengundi ? $saluranMengundi->id : null; return [ 'number' => [ 'required', 'string', 'max:20', Rule::unique('saluran_mengundis', 'number') ->where(fn ($query) => $query->where('pusat_mengundi_id', $pusatId)) ->ignore($saluranId), ], 'voter_count' => ['nullable', 'integer', 'min:0'], ]; } }