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