Clerk.php 1.2 KB

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