123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 套餐项目模型
- * Class Users
- * @packagegoods app\admin\model
- */
- class LifePackageGoods 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 = 'life_package_goods';
- public $timestamps = false;
- /**
- * Notes:获取套餐项目列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: YCP
- * Date: 2022/10/18
- */
- public static function getPackageGoodsList(int $page, int $limit, string $keywords)
- {
- $list = static::select('*')
- ->where(['goods_is_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('goods_name', 'like', '%' . $keywords . '%');
- })
- ->orderBy('goods_weigh','DESC')
- ->forPage($page, $limit)
- ->get();
- $count = static::where(['goods_is_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: YCP
- * Date: 2022/10/18
- */
- public static function getPackageGoodsAll()
- {
- $list = static::select(['goods_id','goods_name'])
- ->where(['goods_is_del'=>static::IS_DEL_NO])
- ->orderBy('goods_create_time','DESC')
- ->get();
- return $list;
- }
- /**
- * Notes:获取套餐项目名称
- * @param string $account
- * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
- * User: YCP
- * Date: 2022/10/18
- */
- public static function packageGoodsMation($admin_packagegoods)
- {
- $where = [];
- $where['goods_is_del'] = static::IS_DEL_NO;
- $mation = static::where($where)
- ->when($admin_packagegoods != '', function ($query) use ($admin_packagegoods){
- $query->whereIn('goods_id', $admin_packagegoods);
- })
- ->get('goods_name');
- return $mation;
- }
- /**
- * Notes:检测套餐项目名是否存在
- * @param $doctor_name
- * @param $doctor_mobile
- * @return bool
- * User: YCP
- * Date: 2022/10/18
- * 验证条件:套餐项目名存在的情况下
- */
- public static function checkPackageGoodsName($packagegoods_name)
- {
- return static::where(['goods_name' => $packagegoods_name, 'goods_is_del' => static::IS_DEL_NO])->exists();
- }
- //时间格式
- public function getGoodsCreateTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- }
|