截流自动化的商城平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

SupplierValidate.php 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\shop\validate\goods;
  20. use app\common\basics\Validate;
  21. use app\common\model\goods\Goods;
  22. /**
  23. * 供货商
  24. * Class SupplierValidate
  25. * @package app\admin\validate
  26. */
  27. class SupplierValidate extends Validate
  28. {
  29. protected $rule = [
  30. 'id' => 'require',
  31. 'name' => 'require|unique:supplier,name&del',
  32. 'contact' => 'require',
  33. 'mobile' => 'require|mobile',
  34. 'address' => 'require',
  35. ];
  36. protected $message = [
  37. 'id.require' => '参数缺失',
  38. 'name.require' => '参数缺失',
  39. 'name.unique' => '该名称已被使用',
  40. 'contact.require' => '请填写联系人',
  41. 'mobile.require' => '请填写联系电话',
  42. 'mobile.mobile' => '请填写正确联系电话',
  43. 'address.require' => '请填写联系地址',
  44. ];
  45. protected $scene = [
  46. 'add' => ['name', 'contact', 'mobile', 'address'],
  47. 'edit' => ['name', 'contact', 'mobile', 'address'],
  48. ];
  49. public function sceneDel()
  50. {
  51. return $this->only(['id'])
  52. ->append('id','checkDel');
  53. }
  54. protected function checkDel($value,$rule,$data)
  55. {
  56. $check = Goods::where('supplier_id', $value)->find();
  57. if ($check) {
  58. return '供货商已经关联商品,无法删除';
  59. }
  60. return true;
  61. }
  62. }