|
|
@@ -0,0 +1,162 @@
|
|
|
+<?php
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
+// | 开源版本可自由商用,可去除界面版权logo
|
|
|
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
+// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
+// | 访问官网:https://www.likeadmin.cn
|
|
|
+// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+// | author: likeadminTeam
|
|
|
+// +----------------------------------------------------------------------
|
|
|
+
|
|
|
+namespace app\adminapi\validate\agricultural_machinery;
|
|
|
+
|
|
|
+use app\common\validate\BaseValidate;
|
|
|
+use app\common\model\supply_demand\SupplyDemandInfo;
|
|
|
+use app\common\model\user\User;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 供需管理验证
|
|
|
+ * Class ArticleCateValidate
|
|
|
+ * @package app\adminapi\validate\article
|
|
|
+ */
|
|
|
+class SupplyDemandValidate extends BaseValidate
|
|
|
+{
|
|
|
+ protected $rule = [
|
|
|
+ 'id' => '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']);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|