123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- class GoodsResource extends BaseModel
- {
- public $page_info;
-
- public function getGoodsResourceList($condition, $pagesize = 0, $order = 'goods_resource_id desc')
- {
- if ($pagesize) {
- $res = Db::name('goods_resource')->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();
- }
- }
-
- public function getGoodsResourceInfo($condition)
- {
- return Db::name('goods_resource')->where($condition)->find();
- }
-
- public function addGoodsResource($data)
- {
- return Db::name('goods_resource')->insertGetId($data);
- }
-
- public function editGoodsResource($data, $condition)
- {
- return Db::name('goods_resource')->where($condition)->update($data);
- }
-
- 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;
- }
- }
|