Store.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model;
  13. use cores\BaseModel;
  14. /**
  15. * 商家记录表模型
  16. * Class Store
  17. * @package app\common\model
  18. */
  19. class Store extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'store';
  23. // 定义主键
  24. protected $pk = 'store_id';
  25. /**
  26. * 关联logo图片
  27. * @return \think\model\relation\HasOne
  28. */
  29. public function logoImage()
  30. {
  31. return $this->hasOne('UploadFile', 'file_id', 'logo_image_id');
  32. }
  33. /**
  34. * 详情信息
  35. * @param int $storeId
  36. * @return array|null|static
  37. */
  38. public static function detail(int $storeId)
  39. {
  40. return self::get($storeId, ['logoImage']);
  41. }
  42. /**
  43. * 获取列表数据
  44. * @param bool $isRecycle 是否在回收站
  45. * @return \think\Paginator
  46. * @throws \think\db\exception\DbException
  47. */
  48. public function getList(bool $isRecycle = false): \think\Paginator
  49. {
  50. return $this->where('is_recycle', '=', (int)$isRecycle)
  51. ->where('is_delete', '=', 0)
  52. ->order(['create_time' => 'desc', $this->getPk()])
  53. ->paginate(15);
  54. }
  55. }