Store.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /**
  14. * 商家记录表模型
  15. * Class Store
  16. * @package app\common\model
  17. */
  18. class Store extends BaseModel
  19. {
  20. // 定义表名
  21. protected $name = 'store';
  22. // 定义主键
  23. protected $pk = 'store_id';
  24. /**
  25. * 关联logo图片
  26. * @return \think\model\relation\HasOne
  27. */
  28. public function logoImage()
  29. {
  30. return $this->hasOne('UploadFile', 'file_id', 'logo_image_id');
  31. }
  32. /**
  33. * 详情信息
  34. * @param int $storeId
  35. * @return array|null|static
  36. */
  37. public static function detail(int $storeId)
  38. {
  39. return self::get($storeId, ['logoImage']);
  40. }
  41. /**
  42. * 获取列表数据
  43. * @param bool $isRecycle 是否在回收站
  44. * @return \think\Paginator
  45. * @throws \think\db\exception\DbException
  46. */
  47. public function getList(bool $isRecycle = false)
  48. {
  49. return $this->where('is_recycle', '=', (int)$isRecycle)
  50. ->where('is_delete', '=', 0)
  51. ->order(['create_time' => 'desc', $this->getPk()])
  52. ->paginate(15);
  53. }
  54. }