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; } } }