UserBrokerageDao.php 946 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\common\dao\user;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\BaseModel;
  5. use app\common\model\user\UserBrokerage;
  6. class UserBrokerageDao extends BaseDao
  7. {
  8. protected function getModel(): string
  9. {
  10. return UserBrokerage::class;
  11. }
  12. public function search(array $where)
  13. {
  14. return UserBrokerage::getDB()->when(isset($where['brokerage_name']) && $where['brokerage_name'] !== '', function ($query) use ($where) {
  15. $query->whereLike('brokerage_name', "%{$where['brokerage_name']}%");
  16. })->when(isset($where['brokerage_level']) && $where['brokerage_level'] !== '', function ($query) use ($where) {
  17. $query->where('brokerage_level', $where['brokerage_level']);
  18. })->when(isset($where['next_level']) && $where['next_level'] !== '', function ($query) use ($where) {
  19. $query->where('brokerage_level', '>', $where['next_level']);
  20. });
  21. }
  22. }