AssetAreaValidate.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\validate\asset;
  15. use app\common\validate\BaseValidate;
  16. use app\common\model\asset\AssetArea;
  17. /**
  18. * 资产地址管理验证
  19. * Class ArticleValidate
  20. * @package app\adminapi\validate\article
  21. */
  22. class AssetAreaValidate extends BaseValidate
  23. {
  24. protected $rule = [
  25. 'id' => 'require|checkAssetInfo',
  26. 'title' => 'require|length:1,50',
  27. ];
  28. protected $message = [
  29. 'id.require' => '资产地址id必传',
  30. 'title.require' => '地址名称不能为空',
  31. 'title.length' => '地址名称长度须在1-55位字符',
  32. ];
  33. /**
  34. * @notes 添加场景
  35. * @return ArticleValidate
  36. * @author heshihu
  37. * @date 2022/2/22 9:57
  38. */
  39. public function sceneAdd()
  40. {
  41. return $this->remove(['id'])
  42. ->remove('id','require|checkAssetInfo');
  43. }
  44. /**
  45. * @notes 详情场景
  46. * @return ArticleValidate
  47. * @author heshihu
  48. * @date 2022/2/22 10:15
  49. */
  50. public function sceneDetail()
  51. {
  52. return $this->only(['id']);
  53. }
  54. public function sceneEdit()
  55. {
  56. }
  57. /**
  58. * @notes 删除场景
  59. * @return ArticleValidate
  60. * @author heshihu
  61. * @date 2022/2/22 10:17
  62. */
  63. public function sceneDelete()
  64. {
  65. return $this->only(['id']);
  66. }
  67. /**
  68. * @notes 检查指定地址是否存在
  69. * @param $value
  70. * @return bool|string
  71. * @author heshihu
  72. * @date 2022/2/22 10:11
  73. */
  74. public function checkAssetInfo($value)
  75. {
  76. $article = AssetArea::findOrEmpty($value);
  77. if ($article->isEmpty()) {
  78. return '地址不存在';
  79. }
  80. return true;
  81. }
  82. }