'require', 'title' => 'require', 'cid' => 'require|checkCid', 'is_show' => 'in:0,1', ]; protected $message = [ 'title.require' => '标题不能为空', 'cid.require' => '请选择分类', 'is_show.in' => '是否显示类型错误', ]; /** * @notes 添加文章/帮助场景 * @return ArticleValidate * @author Tab * @date 2021/7/22 17:06 */ public function sceneAdd() { return $this->remove('id', 'require'); } /** * @notes 获取文章/帮助详情场景 * @return ArticleValidate * @author Tab * @date 2021/7/22 17:06 */ public function sceneDetail() { return $this->only(['id']); } /** * @notes 删除文章/帮助场景 * @return ArticleValidate * @author Tab * @date 2021/7/22 17:06 */ public function sceneDelete() { return $this->only(['id']); } /** * @notes 文章显示或隐藏场景 * @return ArticleValidate * @author Tab * @date 2021/7/22 17:07 */ public function sceneShow() { return $this->only(['id']); } /** * @notes 校验文章/帮助分类 * @param $value * @return bool|string * @author Tab * @date 2021/7/22 17:08 */ public function checkCid($value) { $articleCategory = ArticleCategory::findOrEmpty($value); if($articleCategory->isEmpty()) { return '分类不存在'; } return true; } }