'array', // 'tags'=>'array', 'market_ids'=>'array', 'spec'=>'array', ]; public static $_TYPE = ['flash_sale'=>'秒杀','group_buy'=>'团购','new_product'=>'新品']; public static $_ONSALE = ['否','是']; public static $_ISINFINITE = ['关闭','开启']; public static $_CAN_USE_COUPON = ['否','是']; public function getCoverImgUrlAttribute($value) { $value = $value ? $value : $this->cover_img; return $this->imageUrl($value); } public function getTypeTextAttribute($value) { $value = $value ? $value : $this->type; return isset(self::$_TYPE[$value]) ? self::$_TYPE[$value] : ''; } public function getOnSaleTextAttribute($value) { $value = $value ? $value : $this->on_sale; return isset(self::$_ONSALE[$value]) ? self::$_ONSALE[$value] : ''; } public function getIsInfiniteTextAttribute($value) { $value = $value ? $value : $this->is_infinite; return isset(self::$_ISINFINITE[$value]) ? self::$_ISINFINITE[$value] : ''; } public function getCanUseCouponTextAttribute($value) { $value = $value ? $value : $this->can_use_coupon; return isset(self::$_CAN_USE_COUPON[$value]) ? self::$_CAN_USE_COUPON[$value] : ''; } public function getExpireTimeTextAttribute() { $value = $this->expire_time; return empty($value) ? '' : date('Y-m-d H:i:s',$value); } public function ImageBanners(){ return $this->hasMany('\App\Models\v3\GoodsActivityBanners','goods_id','id')->where('type',1); } public function VideoBanners(){ return $this->hasMany('\App\Models\v3\GoodsActivityBanners','goods_id','id')->where('type',2); } public function setExpireTimeAttribute($value){ $this->attributes['expire_time'] = strtotime($value); } /** * 处理旧图片 * @param $value * @return string */ public function imageUrl($value) { if(strripos($value,"http") === false){ return config('filesystems.disks.oss.img_host').'/'.$value; }else{ return $value; } } }