model->where($where)->orderByRaw('article_order desc,created_at desc'); if ($page) { return $res->paginate($page); } else { return $res->get(); } } /* *根据分类查询 */ public function getPolicy($where,$page) { return $this->model->whereHas('show_category',function ($query) use ($where){ $query->where($where); })->paginate($page); } /** * @param $where array * @return null|\Illuminate\Database\Eloquent\Model */ public function getAllPolicys($where, $orWhere, $page) { $res = $this->model->where(function ($query) use ($where, $orWhere) { $query->where($where)->orwhere($orWhere); })->orderByRaw('article_order desc,created_at desc'); if ($page) { return $res->paginate($page); } else { return $res->get(); } } public function getFocosPolicys($focos, $limit) { $where = array('is_display'=>'1','focos'=>$focos); return $this->model->where($where)->orderByRaw('article_order desc,created_at desc,id desc')->limit($limit)->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 filterPolicys($where = array(), $whereIn = array(), $order = array()) { $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(); } }