CompanyStaff.php 935 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Model;
  5. /**
  6. * 商家员工
  7. */
  8. class CompanyStaff extends Model
  9. {
  10. // 表名
  11. protected $name = 'company_staff';
  12. public function company()
  13. {
  14. return $this->hasOne('Company', 'id', 'company_id',[],'LEFT');
  15. }
  16. /**
  17. * 获取员工列表
  18. * @param $params
  19. * @return array|bool|\PDOStatement|string|\think\Collection
  20. */
  21. public static function getStaffList($params=[])
  22. {
  23. $companyId = isset($params['company_id']) ? $params['company_id'] : 0;
  24. $type = isset($params['type']) ? $params['type'] : 0;
  25. $company = [];
  26. if (!empty($companyId)) {
  27. $field = 'id,truename,mobile';
  28. !empty($type) && $where['type'] = $type;
  29. $where['company_id'] = $companyId;
  30. $company = self::field($field)->where($where)->select();
  31. }
  32. return $company;
  33. }
  34. }