4
0
Fork 0

sku detaul

master
panliang 2022-08-02 15:38:39 +08:00
parent c923c50abe
commit 41eafd3cdd
2 changed files with 14 additions and 13 deletions

View File

@ -5,7 +5,7 @@
@foreach($value as $item)
<div class="mt-1">
<span class="label bg-info">{{ $item['name'] }}</span>
<span>{{ $item['value'] }}</span>
<span>{{ $item['value'] }} {{ isset($item['price']) ? '(+'.$item['price'].')' : '' }}</span>
</div>
@endforeach
@endif

View File

@ -59,24 +59,25 @@ class GoodsSkuController extends Controller
->body($grid);
}
public function show($id, Content $content)
public function show($goods, $id, Content $content)
{
$info = GoodsSku::with(['goods'])->findOrFail($id);
$goods = Goods::findOrFail($goods);
$info = GoodsSku::findOrFail($id);
$show = Show::make($info, function (Show $show) {
$show->field('sn');
$show->field('name');
$show->field('price');
$show->field('stock');
// $show->field('spec')->view('peidikeji.dcat-admin-extension-goods::grid.attr');
$goods = $show->model()->goods;
foreach($goods->spec as $key => $item) {
$show->field('spec_' . $key, $item['name'])->as(function () use ($item) {
$filtered = current(array_filter($this->spec, fn($subItem) => $subItem['name'] === $item['name']));
$value = data_get($filtered, 'value');
$price = data_get($filtered, 'price');
return '<span class="label bg-info">'.$value.'</span>';
})->unescape();
}
$show->field('spec')->view('peidikeji.dcat-admin-extension-goods::grid.attr');
// $goods = $show->model()->goods;
// foreach($goods->spec as $key => $item) {
// $show->field('spec_' . $key, $item['name'])->as(function () use ($item) {
// $filtered = current(array_filter($this->spec, fn($subItem) => $subItem['name'] === $item['name']));
// $value = data_get($filtered, 'value');
// $price = data_get($filtered, 'price');
// return '<span class="label bg-info">'.$value.'</span>';
// })->unescape();
// }
});
return $content
->translation($this->translation)