| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?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\asset;
- use app\common\validate\BaseValidate;
- use app\common\model\asset\AssetInfo;
- /**
- * 资产管理验证
- * Class ArticleValidate
- * @package app\adminapi\validate\article
- */
- class AssetValidate extends BaseValidate
- {
- protected $rule = [
- 'id' => 'require|checkAssetInfo',
- 'name' => 'require|length:1,255',
- 'images' => 'require',
- 'address' => 'require',
- 'contacts' => 'require',
- 'mobile' => 'require',
- 'status' => 'in:0,1',
- ];
- protected $message = [
- 'id.require' => '资产id不能为空',
- 'name.require' => '资产名称不能为空',
- 'name.length' => '资产名称长度须在1-255位字符',
- 'images.require' => '资产图片不能为空',
- 'address.require' => '资产地址不能为空',
- 'contacts.require' => '资产联系人不能为空',
- 'mobile.require' => '联系方式不能为空',
- ];
- /**
- * @notes 添加场景
- * @return ArticleValidate
- * @author heshihu
- * @date 2022/2/22 9:57
- */
- public function sceneAdd()
- {
- return $this->remove(['id'])
- ->remove('id','require|checkAssetInfo');
- }
- /**
- * @notes 详情场景
- * @return ArticleValidate
- * @author heshihu
- * @date 2022/2/22 10:15
- */
- public function sceneDetail()
- {
- return $this->only(['id']);
- }
- /**
- * @notes 更改状态场景
- * @return ArticleValidate
- * @author heshihu
- * @date 2022/2/22 10:18
- */
- public function sceneStatus()
- {
- return $this->only(['id', 'status']);
- }
- public function sceneEdit()
- {
- }
- /**
- * @notes 删除场景
- * @return ArticleValidate
- * @author heshihu
- * @date 2022/2/22 10:17
- */
- public function sceneDelete()
- {
- return $this->only(['id']);
- }
- /**
- * @notes 检查指定资讯是否存在
- * @param $value
- * @return bool|string
- * @author heshihu
- * @date 2022/2/22 10:11
- */
- public function checkAssetInfo($value)
- {
- $article = AssetInfo::findOrEmpty($value);
- if ($article->isEmpty()) {
- return '资产不存在';
- }
- return true;
- }
- }
|