123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- namespace app\admin\model;
- use support\Db;
- use support\Model;
- /**
- * 套餐模型
- * Class Users
- * @package app\admin\model
- */
- class LifePackage 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';
- public $timestamps = false;
- /**
- * Notes:获取套餐列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: YCP
- * Date: 2022/10/18
- */
- public static function getPackageList(int $page, int $limit, string $keywords,$package_type)
- {
- $list = static::select('*')
- ->where(['package_is_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('package_name', 'like', '%' . $keywords . '%');
- })
- ->when($package_type != '', function ($query) use ($package_type){
- $query->where('package_type',$package_type);
- })
- ->orderBy('package_create_time','DESC')
- ->forPage($page, $limit)
- ->get();
- foreach ($list as &$v) {
- $v['package_tags'] = explode(",",$v['package_tags']);
- }
- $count = static::where(['package_is_del'=>static::IS_DEL_NO])
- ->when($keywords != '', function ($query) use ($keywords){
- $query->where('package_name', 'like', '%' . $keywords . '%');
- })
- ->when($package_type != '', function ($query) use ($package_type){
- $query->where('package_type',$package_type);
- })
- ->count();
- return [$list, $count];
- }
- /**
- * Notes:获取套餐列表
- * @return array
- * User: YCP
- * Date: 2022/10/18
- */
- public static function getPackageAll()
- {
- $list = static::select(['package_id','package_name'])
- ->where(['package_is_del'=>static::IS_DEL_NO])
- ->orderBy('package_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 packageMation($admin_package)
- {
- $where = [];
- $where['package_is_del'] = static::IS_DEL_NO;
- $mation = static::where($where)
- ->when($admin_package != '', function ($query) use ($admin_package){
- $query->whereIn('package_id', $admin_package);
- })
- ->get('package_name');
- return $mation;
- }
- /**
- * Notes:检测套餐名是否存在
- * @param $doctor_name
- * @param $doctor_mobile
- * @return bool
- * User: YCP
- * Date: 2022/10/18
- * 验证条件:套餐名存在的情况下
- */
- public static function checkPackageName($package_name)
- {
- return static::where(['package_name' => $package_name, 'package_is_del' => static::IS_DEL_NO])->exists();
- }
- //时间格式
- public function getPackageCreateTimeAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- }
|