You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
965 B

<?php
namespace App\Model\v3;
use App\Constants\v3\OssThumbnail;
use App\Model\Model;
use App\Service\v3\Interfaces\AttachmentServiceInterface;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\Di\Annotation\Inject;
class GoodsBanner extends Model
{
/**
* @Inject
* @var AttachmentServiceInterface
*/
protected $attachmentService;
use SoftDeletes;
protected $table = 'lanzu_goods_banners';
protected $appends = [
'banner_url',
];
protected $fillable = [
'id',
'goods_id',
'path',
'type'
];
public function getBannerUrlAttribute()
{
if($this->attributes['type'] == 1){
return $this->attachmentService->switchImgToAliOss($this->attributes['path'], OssThumbnail::THUMBNAIL_600_Q90);
}elseif ($this->attributes['type'] == 2){
return $this->attachmentService->switchImgToAliOss($this->attributes['path']);
}
}
}