From cda224547997d38237df1924cd656648cb26c0cc Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 6 Sep 2020 12:02:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0coverurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Category.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Model/v3/Category.php b/app/Model/v3/Category.php index 24311b0..b877e4d 100644 --- a/app/Model/v3/Category.php +++ b/app/Model/v3/Category.php @@ -13,7 +13,8 @@ class Category extends Model protected $table = 'lanzu_category'; protected $appends = [ - 'goods_types' + 'goods_types', + 'cover_url' ]; 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(); } + + public function getCoverUrlAttribute() + { + $url = $this->attributes['cover_img']; + + if(strripos($url,"http") === false){ + return config('alioss.img_host').'/'.$url; + }else{ + return $url; + } + } } \ No newline at end of file