|
|
|
@ -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'); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |