产品详情页添加品牌信息

This commit is contained in:
Edward Yang 2023-01-05 18:37:25 +08:00
parent 8384db4911
commit 4f5b2821e6
4 changed files with 9 additions and 3 deletions

View File

@ -34,7 +34,7 @@ class ProductRepo
if (is_int($product)) {
$product = Product::query()->findOrFail($product);
}
$product->load('description', 'skus', 'master_sku');
$product->load('description', 'skus', 'master_sku', 'brand');
return $product;
}

View File

@ -125,10 +125,13 @@ class SettingRepo
/**
* 创建或更新单条记录
*
* @param $data
* @param $name
* @param $value
* @param string $space
* @param string $type
* @throws \Throwable
*/
public static function storeValue($name, $value, $space = 'base', $type = 'system')
public static function storeValue($name, $value, string $space = 'base', string $type = 'system')
{
if (in_array($name, ['_method', '_token'])) {
return;

View File

@ -22,6 +22,7 @@ class ProductController extends Controller
$data = [
'product' => (new ProductDetail($product))->jsonSerialize(),
];
$data = hook_filter('product.show', $data);
return view('product', $data);
}

View File

@ -25,6 +25,8 @@ class ProductDetail extends JsonResource
'id' => $this->id,
'name' => $this->description->name ?? '',
'description' => $this->description->content ?? '',
'brand_id' => $this->brand->id ?? 0,
'brand_name' => $this->brand->name ?? '',
'images' => array_map(function ($image) {
return [
'preview' => image_resize($image, 500, 500),