where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false); $this->page_info = $res; return $res->items(); } else { return Db::name('goods_resource')->where($condition)->order($order)->select()->toArray(); } } /** * 取单个内容 * @access public * @author csdeshang * @param int $id 分类ID * @return array 数组类型的返回结果 */ public function getGoodsResourceInfo($condition) { return Db::name('goods_resource')->where($condition)->find(); } /** * 新增 * @access public * @author csdeshang * @param array $data 参数内容 * @return bool 布尔类型的返回结果 */ public function addGoodsResource($data) { return Db::name('goods_resource')->insertGetId($data); } /** * 更新信息 * @access public * @author csdeshang * @param array $data 更新数据 * @param array $condition 条件数组 * @return bool 布尔类型的返回结果 */ public function editGoodsResource($data, $condition) { return Db::name('goods_resource')->where($condition)->update($data); } /** * 删除图片信息,根据where * @access public * @author csdeshang * @param array $condition 条件数组 * @return bool 布尔类型的返回结果 */ public function delGoodsResource($condition, $store_id) { if (empty($condition)) { return false; } $image_more = Db::name('goods_resource')->where($condition)->field('file_name')->select()->toArray(); if (is_array($image_more) && !empty($image_more)) { foreach ($image_more as $v) { @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_GOODS_RESOURCE . DIRECTORY_SEPARATOR . $store_id . DIRECTORY_SEPARATOR . $v['file_name']); } } $state = Db::name('goods_resource')->where($condition)->delete(); return $state; } }