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

View File

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