Merchant.php 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\models\merchant;
  3. use crmeb\basic\BaseModel;
  4. use crmeb\traits\ModelTrait;
  5. class Merchant extends BaseModel
  6. {
  7. /**
  8. * 数据表主键
  9. * @var string
  10. */
  11. protected $pk = 'id';
  12. /**
  13. * 模型名称
  14. * @var string
  15. */
  16. protected $name = 'merchant';
  17. use ModelTrait;
  18. public static function getList($where = null)
  19. {
  20. $data = ($data = self::setWhere($where)->select()) && count($data) ? $data->toArray() : [];
  21. $count = self::setWhere($where)->count();
  22. return ['count' => $count, 'list' => $data];
  23. }
  24. public static function setWhere($where)
  25. {
  26. $model = (new self);
  27. if ($where['name']) {
  28. $model = $model->where('name', 'like', '%' . $where['name'] . '%');
  29. }
  30. return $model;
  31. }
  32. }