'require|checkCateInfo', 'name' => 'require|checkName', 'status' => 'requireIf:status,0|in:0,1', 'pid'=>'require|checkPid', ]; protected $message = [ 'id.require' => '供需分类id不能为空', 'name.require' => '请输入分类名称', 'status.require' => '状态必传', 'status.in' => '状态参数规则错误', 'pid.require' => '请父级分类必传', ]; /** * @notes 列表 * @return ArticleCateValidate * @author heshihu * @date 2022/2/10 15:11 */ public function scenesupplyDemandCate() { 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|checkCateInfo'); } /** * @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 sceneEdit() { return $this ->remove('type', 'require'); } /** * @notes 获取所有农耕分类场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/15 10:05 */ public function sceneStatus() { return $this->only(['id','status']); } /** * @notes 删除场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/21 17:52 */ public function sceneDelete() { return $this->only(['id']) ->append('id', 'checkCateInfo'); } /** * @notes 检查指定服务信息是否存在 * @param $value * @return bool|string * @author heshihu * @date 2022/2/10 15:10 */ public function checkName($value){ $category = SupplyDemandCate::where(['name'=>$value])->findOrEmpty(); if (!$category->isEmpty()) { return '已存在改分类名称'; } return true; } public function checkPid($value) { if($value == 0) return true; $category = SupplyDemandCate::findOrEmpty($value); if ($category->isEmpty()) { return '父级分类不存在'; } return true; } public function checkUserInfo($value,$data) { $category = User::findOrEmpty($value); if ($category->isEmpty()) { return '用户信息不存在'; } return true; } public function checkCateInfo($value) { $category = SupplyDemandCate::findOrEmpty($value); if ($category->isEmpty()) { return '分类不存在'; } return true; } }