Browse Source

添加url显示

(cherry picked from commit 914661547b)
master
Mike 5 years ago
committed by weigang
parent
commit
17f1035ac1
  1. 21
      app/Model/v3/Banner.php

21
app/Model/v3/Banner.php

@ -11,10 +11,27 @@ 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');
});
}
}
Loading…
Cancel
Save