Clerk.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model\store\shop;
  3. use app\common\model\BaseModel;
  4. /**
  5. * 商家门店店员模型
  6. * Class Clerk
  7. * @package app\common\model\store
  8. */
  9. class Clerk extends BaseModel
  10. {
  11. protected $name = 'store_shop_clerk';
  12. /**
  13. * 关联用户表
  14. * @return \think\model\relation\BelongsTo
  15. */
  16. public function user()
  17. {
  18. $module = static::getCalledModule() ?: 'common';
  19. return $this->BelongsTo("app\\{$module}\\model\\User");
  20. }
  21. /**
  22. * 关联门店表
  23. * @return \think\model\relation\BelongsTo
  24. */
  25. public function shop()
  26. {
  27. $module = static::getCalledModule() ?: 'common';
  28. return $this->BelongsTo("app\\{$module}\\model\\store\\Shop");
  29. }
  30. /**
  31. * 店员详情
  32. * @param $where
  33. * @return static|null
  34. * @throws \think\exception\DbException
  35. */
  36. public static function detail($where)
  37. {
  38. $filter = is_array($where) ? $where : ['clerk_id' => $where];
  39. return static::get(array_merge(['is_delete' => 0], $filter));
  40. }
  41. }