<?php



namespace app\common\dao\user;


use app\common\dao\BaseDao;
use app\common\model\BaseModel;
use app\common\model\user\UserBrokerage;

class UserBrokerageDao extends BaseDao
{

    protected function getModel(): string
    {
        return UserBrokerage::class;
    }

    public function search(array $where)
    {
        return UserBrokerage::getDB()->when(isset($where['brokerage_name']) && $where['brokerage_name'] !== '', function ($query) use ($where) {
            $query->whereLike('brokerage_name', "%{$where['brokerage_name']}%");
        })->when(isset($where['brokerage_level']) && $where['brokerage_level'] !== '', function ($query) use ($where) {
            $query->where('brokerage_level', $where['brokerage_level']);
        })->when(isset($where['next_level']) && $where['next_level'] !== '', function ($query) use ($where) {
            $query->where('brokerage_level', '>', $where['next_level']);
        });
    }
}