'require|checkMachineryCate', 'name' => 'require|length:1,60', 'status' => 'require|in:0,1', 'sort' => 'egt:0', 'type' =>'require|in:1,2,3', ]; protected $message = [ 'id.require' => ' 分类id不能为空', 'name.require' => '分类名称不能为空', 'name.length' => '分类长度须在1-60位字符', 'sort.egt' => '排序值不正确', 'type.require' => '类型不能为空', 'type.in' => '类型值type参数规则错误', ]; /** * @notes 列表 * @return ArticleCateValidate * @author heshihu * @date 2022/2/10 15:11 */ public function sceneList() { return $this->only(['type']); } /** * @notes 添加场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/10 15:11 */ public function sceneAdd() { return $this->remove(['id']) ->remove('id', 'require|checkMachineryCate'); } /** * @notes 详情场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/21 17:55 */ public function sceneDetail() { return $this->only(['id']); } /** * @notes 更改状态场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/21 18:02 */ public function sceneStatus() { return $this->only(['id', 'status']); } public function sceneEdit() { return $this ->remove('type', 'require'); } /** * @notes 获取所有农耕分类场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/15 10:05 */ public function sceneSelect() { // return $this->only(['type']); } /** * @notes 删除场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/21 17:52 */ public function sceneDelete() { return $this->only(['id']) ->append('id', 'checkDeleteArticleCate'); } /** * @notes 检查指定农耕分类是否存在 * @param $value * @return bool|string * @author heshihu * @date 2022/2/10 15:10 */ public function checkMachineryCate($value) { $category = AgriculturalMachineryServiceCategory::findOrEmpty($value); if ($category->isEmpty()) { return '农耕分类不存在'; } return true; } /** * @notes 删除时验证农耕分类是否已使用 * @param $value * @return bool|string * @author heshihu * @date 2022/2/22 14:45 */ public function checkDeleteArticleCate($value) { // $article = Article::where('cid', $value)->findOrEmpty(); // if (!$article->isEmpty()) { // return '农耕分类已使用,请先删除绑定该农耕分类的农耕服务'; // } return true; } }