Browse Source

商品 模型

master
Lemon 5 years ago
parent
commit
13df9a6196
  1. 6
      app/Model/v3/Goods.php
  2. 2
      app/Service/v3/Implementations/GoodsService.php

6
app/Model/v3/Goods.php

@ -63,6 +63,7 @@ class Goods extends Model
'is_effective', 'is_effective',
'noneffective_note', 'noneffective_note',
'details_imgs_url', 'details_imgs_url',
'goods_name'
]; ];
protected function boot(): void protected function boot(): void
@ -125,6 +126,11 @@ class Goods extends Model
}); });
} }
public function getGoodsNameAttribute()
{
return $this->attributes['name'];
}
public function getNameAttribute($value) public function getNameAttribute($value)
{ {
return $value . ' ' . $this->attributes['goods_unit']; return $value . ' ' . $this->attributes['goods_unit'];

2
app/Service/v3/Implementations/GoodsService.php

@ -92,7 +92,7 @@ class GoodsService implements GoodsServiceInterface
public function info($goodsId) public function info($goodsId)
{ {
$res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->select('*','name as goods_name')->first();
$res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->first();
return $res; return $res;
} }
} }
Loading…
Cancel
Save