SystemSupplier.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\model\supplier;
  12. use app\model\system\admin\SystemAdmin;
  13. use crmeb\basic\BaseModel;
  14. use crmeb\traits\ModelTrait;
  15. use think\Model;
  16. /**
  17. * 供应商模型
  18. * Class SystemSupplier
  19. * @package app\model\store
  20. */
  21. class SystemSupplier extends BaseModel
  22. {
  23. use ModelTrait;
  24. /**
  25. * 数据表主键
  26. * @var string
  27. */
  28. protected $pk = 'id';
  29. /**
  30. * 模型名称
  31. * @var string
  32. */
  33. protected $name = 'system_supplier';
  34. /**
  35. * 管理员
  36. * @return \think\model\relation\HasOne
  37. */
  38. public function admin()
  39. {
  40. return $this->hasOne(SystemAdmin::class, 'id', 'admin_id')->field(['id', 'account', 'pwd', 'admin_type', 'is_del', 'level', 'roles'])->bind([
  41. 'account',
  42. 'pwd',
  43. 'admin_type',
  44. 'level',
  45. 'roles',
  46. 'admin_is_del' => 'is_del',
  47. ]);
  48. }
  49. /**
  50. * 手机号,id,昵称搜索器
  51. * @param Model $query
  52. * @param $value
  53. */
  54. public function searchKeywordsAttr($query, $value)
  55. {
  56. if ($value != '') {
  57. $query->where('supplier_name', 'LIKE', "%$value%");
  58. }
  59. }
  60. /**
  61. * 是否删除搜索器
  62. * @param Model $query
  63. * @param $value
  64. */
  65. public function searchIsDelAttr($query, $value)
  66. {
  67. $query->where('is_del', $value ?? 0);
  68. }
  69. }