route('investment_limit_profile'); $limitId = $this->route('limit'); $typeRule = Rule::unique('profile_investment_limits', 'investment_type_id') ->where(fn ($query) => $query->where('profile_id', $profileId)); if ($this->isMethod('PUT') || $this->isMethod('PATCH')) { $typeRule = $typeRule->ignore($limitId); } return [ 'investment_type_id' => [ 'required', 'uuid', 'exists:investment_types,id', $typeRule, ], 'max_investment_amount' => ['nullable', 'numeric', 'min:0'], 'max_transaction_amount' => ['nullable', 'numeric', 'min:0'], ]; } public function messages(): array { return [ 'investment_type_id.required' => 'Jenis pelaburan diperlukan.', 'investment_type_id.exists' => 'Jenis pelaburan tidak dijumpai.', 'investment_type_id.unique' => 'Had untuk jenis pelaburan ini sudah wujud dalam profil.', ]; } }