'require|checkUserServiceInfo', 'user_id' => 'require|checkUserInfo', 'status' => 'requireIf:status,0|in:0,1,2,3', 'type' =>'require|in:1,2', 'mobile' => 'require|mobile', 'images'=>'require', ]; protected $message = [ 'id.require' => ' 供需id不能为空', 'user_id.require' => '请选择用户', 'type.require' => '类型不能为空', 'type.in' => '类型值type参数规则错误', 'mobile.require' => '联系方式参数缺失', 'mobile.mobile' => '请填写正确的手机号', 'images.require' => '请输入上传服务图片', ]; /** * @notes 列表 * @return ArticleCateValidate * @author heshihu * @date 2022/2/10 15:11 */ public function sceneSupplyDemand() { return $this->only(['status']); } /** * @notes 添加场景 * @return ArticleCateValidate * @author heshihu * @date 2022/2/10 15:11 */ public function sceneAdd() { return $this->remove(['id']) ->remove('id', 'require|checkUserServiceInfo'); } /** * @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'])->append('status', 'checkStatus');; } 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', 'checkUserServiceInfo'); } /** * @notes 检查指定服务信息是否存在 * @param $value * @return bool|string * @author heshihu * @date 2022/2/10 15:10 */ public function checkUserServiceInfo($value) { $category = SupplyDemandInfo::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 checkStatus($value){ 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; } }