1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\admin\model;
- use support\Model;
- /**
- * 养老产品模型
- * Class Users
- * @package app\admin\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 => '未删除'
- ];
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'raise_old_goods';
- public $timestamps = false;
- /**
- * Notes:获取养老产品列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: ZQ
- * Date: 2022/10/14
- */
- 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];
- }
- /**
- * Notes:获取所有养老产品
- * @return array
- * User: ZQ
- * Date: 2022/10/14
- */
- 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;
- }
- /**
- * Notes:获取养老产品名称
- * @param string $account
- * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
- * User: ZQ
- * Date: 2022/10/14
- */
- 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;
- }
- }
|