1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\admin\model;
- use support\Model;
- class RaiseOldGoods extends Model
- {
- const ROLE_STATUS = 1;
- const IS_DEL_YES = 1;
- const IS_DEL_NO = 0;
- const GOODS_IS_SHOW = [
- self::IS_DEL_YES => '已删除',
- self::IS_DEL_NO => '未删除'
- ];
-
- protected $table = 'raise_old_goods';
- public $timestamps = false;
-
- public static function getGoodsList(int $page, int $limit, string $keywords)
- {
- $list = static::select(['raise_old_goods.*','category.category_name','merchant_shop.shop_name'])
- ->where(['goods_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('goods_name', 'like', '%' . $keywords . '%');
- })
- ->leftJoin('category','category_id','=','raise_old_goods.goods_category_id')
- ->leftJoin('merchant_shop','shop_id','=','raise_old_goods.goods_shop_id')
- ->orderBy('goods_add_time','DESC')
- ->orderBy('goods_id','DESC')
- ->forPage($page, $limit)
- ->get();
- $count = static::where(['goods_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('goods_name', 'like', '%' . $keywords . '%');
- })
- ->count();
- return [$list, $count];
- }
-
- public static function getGoodsAll()
- {
- $list = static::select(['goods_id','goods_name'])
- ->where(['goods_del'=>static::IS_DEL_NO])
- ->orderBy('goods_add_time','DESC')
- ->get();
- return $list;
- }
-
- public static function bookMation($admin_cinema)
- {
- $where = [];
- $where['goods_del'] = static::IS_DEL_NO;
- $mation = static::where($where)
- ->when($admin_cinema != '', function ($query) use ($admin_cinema){
- $query->whereIn('goods_id', $admin_cinema);
- })
- ->get('goods_name');
- return $mation;
- }
- }
|