OctoberCMS:如何在违反唯一约束时显示自定义错误消息?

OctoberCMS: How to show custom error message when unique constraint is violated?

当用户尝试使用 FormController 行为在后端创建新模型时,如何替换显示的 "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'upload' for key 错误消息?

使用unique验证规则。参见 https://octobercms.com/docs/services/validation#rule-unique & https://laravel.com/docs/5.5/validation#rule-unique