diff --git a/app/Model/v3/Banner.php b/app/Model/v3/Banner.php index 6953299..b022df2 100644 --- a/app/Model/v3/Banner.php +++ b/app/Model/v3/Banner.php @@ -10,11 +10,28 @@ class Banner extends Model { use SoftDeletes; protected $table = 'lanzu_banners'; + + protected $appends = [ + 'cover_url' + ]; protected $visible = [ - 'id', 'cover', 'cover_type', 'title', 'subtitle', 'path', 'path_type', 'bg_color' + 'id', 'cover_type', 'title', 'subtitle', 'path', 'path_type', 'bg_color','cover_url' ]; + public function getCoverUrlAttribute(){ + return $this->imageUrl($this->cover); + } + + public function imageUrl($value) + { + if(strripos($value,"http") === false){ + return env('OSS_IMG_HOST').'/'.$value; + }else{ + return $value; + } + } + protected function boot(): void { parent::boot(); @@ -22,4 +39,6 @@ class Banner extends Model return $builder->where(['status' => 1])->orderBy('sort', 'desc'); }); } + + } \ No newline at end of file