@extends('layouts.admin')
@section('title', 'Detail Produk')
@section('content')
@if ($product->specifications && $product->specifications->count() > 0)
Spesifikasi Produk
({{ $product->specifications->count() }} item)
@foreach ($product->specifications as $spec)
{{ $spec->key }}:
{{ $spec->value }}
@endforeach
@endif
@php
// Ambil data real dari database
$allMaterials = $product->materials && $product->materials->count() > 0
? $product->materials->map(function($m) {
return [
'item_type' => 'Bahan',
'name' => $m->name,
'quantity' => $m->quantity,
'unit' => $m->unit ?? 'pcs',
'type' => $m->type ?? 'material',
];
})->toArray()
: [];
$allSpareparts = $product->spareparts && $product->spareparts->count() > 0
? $product->spareparts->map(function($s) {
return [
'item_type' => 'Sparepart',
'name' => $s->name,
'quantity' => $s->quantity,
'unit' => $s->unit ?? 'pcs',
'type' => $s->type ?? 'sparepart',
];
})->toArray()
: [];
// Gabungkan semua data
$allItems = array_merge($allMaterials, $allSpareparts);
@endphp
@if (!empty($allItems))
Bahan & Sparepart yang Digunakan
(Total: {{ count($allItems) }} item)
|
No
|
Tipe
|
Nama
|
Jumlah
|
Satuan
|
@foreach ($allItems as $index => $item)
|
{{ $index + 1 }}
|
{{ $item['item_type'] }}
|
{{ $item['name'] }}
|
{{ $item['quantity'] }}
|
{{ $item['unit'] }}
|
@endforeach
@endif
@endsection