From 0068cf1d2e99c2378b8ab0638898cc5be99cf8ab Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 13 Aug 2021 15:19:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9=E5=99=A8?= =?UTF-8?q?=EF=BC=8C=E5=9B=BE=E7=89=87=E4=BF=9D=E5=AD=98=E6=97=B6=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Advertising.php | 7 +++++++ app/Models/Agent.php | 12 ++++++++++++ app/Models/Article.php | 8 +++++++- app/Models/Channel.php | 14 +++++++++++++- app/Models/Order.php | 10 ++++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/app/Models/Advertising.php b/app/Models/Advertising.php index 5ed8a55..787ac3a 100644 --- a/app/Models/Advertising.php +++ b/app/Models/Advertising.php @@ -7,8 +7,15 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; class Advertising extends BaseModel { use HasFactory; + public function getPictureAttribute($value) { return $value ? $this->host . $value : ''; } + + public function setPictureAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['picture'] = str_replace(env('APP_URL'), '', $value); + } } diff --git a/app/Models/Agent.php b/app/Models/Agent.php index 96e7a80..74af22c 100644 --- a/app/Models/Agent.php +++ b/app/Models/Agent.php @@ -19,6 +19,18 @@ class Agent extends BaseModel return $value ? $this->host . $value : ''; } + public function setLogoAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['logo'] = str_replace(env('APP_URL'), '', $value); + } + + public function setLicensePicAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['license_pic'] = str_replace(env('APP_URL'), '', $value); + } + public function setPasswordAttribute($value) { //新增时 diff --git a/app/Models/Article.php b/app/Models/Article.php index cdd74ba..25efcad 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -8,8 +8,14 @@ class Article extends BaseModel { use HasFactory; - public function getImageAttribute($value) + public function getImageAttribute($value): string { return $value ? $this->host . $value : ''; } + + public function setImageAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['image'] = str_replace(env('APP_URL'), '', $value); + } } diff --git a/app/Models/Channel.php b/app/Models/Channel.php index 54c5b35..7659211 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -14,8 +14,20 @@ class Channel extends BaseModel { use HasFactory, SoftDeletes; - public function getIconAttribute($value) + public function __construct(array $attributes = []) + { + parent::__construct($attributes); + $this->timestamps = false; + } + + public function getIconAttribute($value): string { return $value ? $this->host . $value : ''; } + + public function setIconAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['license_pic'] = str_replace(env('APP_URL'), '', $value); + } } diff --git a/app/Models/Order.php b/app/Models/Order.php index 3b6fbe0..61cc223 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -28,7 +28,7 @@ class Order extends BaseModel } //退款信息 - public function getRefundInfoAttribute($value) + public function getRefundInfoAttribute($value): array { $value = $value ? json_decode($value, true) : []; if (!empty($value['pictures']) && is_array($value['pictures'])) { @@ -39,11 +39,17 @@ class Order extends BaseModel return $value ?? []; } - public function getPictureAttribute($value) + public function getPictureAttribute($value): string { return $value ? $this->host . $value : ''; } + public function setPictureAttribute($value) + { + //修改器里面$this->host变量为空 + $this->attributes['picture'] = str_replace(env('APP_URL'), '', $value); + } + public function agentProduct() { return $this->belongsTo(AgentProduct::class);