Browse Source

添加coverurl

master
Mike 5 years ago
parent
commit
cda2245479
  1. 14
      app/Model/v3/Category.php

14
app/Model/v3/Category.php

@ -13,7 +13,8 @@ class Category extends Model
protected $table = 'lanzu_category'; protected $table = 'lanzu_category';
protected $appends = [ protected $appends = [
'goods_types'
'goods_types',
'cover_url'
]; ];
protected function boot(): void protected function boot(): void
@ -28,4 +29,15 @@ class Category extends Model
{ {
return self::query()->where(['parent_id' => $this->attributes['id']])->orderBy('sort', 'desc')->get()->toArray(); return self::query()->where(['parent_id' => $this->attributes['id']])->orderBy('sort', 'desc')->get()->toArray();
} }
public function getCoverUrlAttribute()
{
$url = $this->attributes['cover_img'];
if(strripos($url,"http") === false){
return config('alioss.img_host').'/'.$url;
}else{
return $url;
}
}
} }
Loading…
Cancel
Save