isUpdate()) { return [ 'word' => 'required|max:100|unique:forum_sensitive_words,word', 'replacement' => 'nullable|max:100', 'type' => 'nullable|integer|in:1,2', 'status' => 'nullable|integer|in:0,1', ]; } $id = $this->route('id'); return [ 'word' => [ 'required', 'max:100', Rule::unique('forum_sensitive_words', 'word')->ignore($id), ], 'replacement' => 'nullable|max:100', 'type' => 'nullable|integer|in:1,2', 'status' => 'nullable|integer|in:0,1', ]; } public function messages(): array { return [ 'word.required' => '敏感词不能为空', 'word.unique' => '敏感词已存在', ]; } }