| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | <?phpnamespace App\Repositories;use App\Models\RecuperateApply;use Prettus\Repository\Eloquent\BaseRepository;class RecuperateApplyRepository extends BaseRepository{    /**     * Specify Model class name     *     * @return string     */    public function model()    {        return RecuperateApply::class;    }    /**     * @param $where array     * @param $page mixed     * @param $with array     * @return null|\Illuminate\Database\Eloquent\Model     */    public function getRecuperate($where, $page, $with)    {        $res = $this->model->with($with)->where($where)->orderByRaw('created_at desc');        if ($page) {            return $res->paginate($page);        } else {            return $res->get();        }    }    /**     * @param $where array     * @return null|\Illuminate\Database\Eloquent\Model     */    public function getAllRecuperate($where, $orWhere, $page, $with)    {        $res = $this->model->with($with)->where(function ($query) use ($where, $orWhere) {            $query->where($where)->orwhere($orWhere);        })->orderByRaw('created_at desc');        if ($page) {            return $res->paginate($page);        } else {            return $res->get();        }    }    public function firstWhere($where)    {        return $this->model->where($where)->first();    }    public function incrementData($where, $num, $filed)    {        return $this->model->where($where)->increment($filed, $num);    }    public function filterRecuperate($where = [], $whereIn = [], $order = [])    {        $rst = $this->model->where($where);        if ($whereIn) {            foreach ($whereIn as $k => $v) {                $rst->whereIn($k, $v);            }        }        if ($order) {            if (is_array($order)) {                foreach ($order as $k => $v) {                    $rst->orderBy($k, $v);                }            } else {                $rst->orderbyRaw($order);            }        }        return $rst->get();    }    public function createApply($attr)    {        $this->model->user_name          = $attr['user_name'] ?? '';        $this->model->user_idcard        = $attr['user_idcard'] ?? '';        $this->model->mobile             = $attr['mobile'] ?? '';        $this->model->wechat             = $attr['wechat'] ?? '';        $this->model->level              = $attr['level'] ?? 0;        $this->model->company_name       = $attr['company_name'] ?? '';        $this->model->validate_time      = $attr['validate_time'] ?? '';        $this->model->salary             = $attr['salary'] ?? 2;        $this->model->tax                = $attr['tax'] ?? 2;        $this->model->condition          = $attr['condition'] ?? 0;        $this->model->uid                = $attr['uid'] ?? 0;        $this->model->recuperate_id      = $attr['recuperate_id'] ?? 0;        $this->model->price              = $attr['price'] ?? 0;        $this->model->recuperate_time_id = $attr['recuperate_time_id'] ?? 0;        $res                             = $this->model->save();        if ($res) {            return true;        } else {            return false;        }    }}
 |