@extends('layouts.app') @section('title', 'Edit Bill of Materials') @section('content') Edit Bill of Materials @include('manufacturing.partials.navigation') Edit BOM: {{ $model->name }} @csrf @method('PUT') BOM Code * Code cannot be changed BOM Name * @error('name') {{ $message }} @enderror Product * Select Product @foreach($products ?? [] as $product) product_id) == $product->id ? 'selected' : '' }} data-unit="{{ $product->unit_id }}"> {{ $product->sku }} - {{ $product->name }} @if($product->unit) {{ $product->unit->actual_name }} @endif @endforeach @error('product_id') {{ $message }} @enderror Status status) == 'draft' ? 'selected' : '' }}>Draft status) == 'active' ? 'selected' : '' }}>Final status) == 'inactive' ? 'selected' : '' }}>Inactive status) == 'obsolete' ? 'selected' : '' }}>Obsolete @error('status') {{ $message }} @enderror Quantity Produced * @error('quantity') {{ $message }} @enderror Quantity this BOM produces Unit of Measure Select Unit @if($model->product && $model->product->unit) @php $productUnitId = $model->product->unit_id; $businessId = $model->business_id; $relatedUnits = \App\Unit::where('business_id', $businessId) ->where(function($q) use ($productUnitId) { $q->where('id', $productUnitId) ->orWhere('base_unit_id', $productUnitId); }) ->get(); @endphp @foreach($relatedUnits as $unit) unit_of_measure) == $unit->id ? 'selected' : '' }}> {{ is_null($unit->base_unit_id) ? '' : '↳ ' }}{{ $unit->actual_name }} @if($unit->base_unit_multiplier) (1 = {{ $unit->base_unit_multiplier }}) @endif @endforeach @endif @error('unit_of_measure') {{ $message }} @enderror Units related to the selected product Effective Date @error('effective_date') {{ $message }} @enderror Expiry Date @error('expiry_date') {{ $message }} @enderror Notes {{ old('notes', $model->notes) }} @error('notes') {{ $message }} @enderror is_default) ? 'checked' : '' }}> Set as Default BOM Make this the default BOM for the selected product Components ({{ $model->components->count() }}) Add Component @foreach($model->components as $index => $component) Raw Material * Select Material @foreach($rawMaterials ?? [] as $material) raw_material_id) == $material->id ? 'selected' : '' }} data-unit-id="{{ $material->unit_id }}"> {{ $material->sku }} - {{ $material->name }} @endforeach Quantity * quantity_required) }}"> Unit Select Unit @if($component->rawMaterial && $component->rawMaterial->unit) @php $productUnitId = $component->rawMaterial->unit_id; $businessId = $model->business_id; $relatedUnits = \App\Unit::where('business_id', $businessId) ->where(function($q) use ($productUnitId) { $q->where('id', $productUnitId) ->orWhere('base_unit_id', $productUnitId); }) ->get(); @endphp @foreach($relatedUnits as $unit) unit_of_measure) == $unit->id ? 'selected' : '' }}> {{ is_null($unit->base_unit_id) ? '' : '↳ ' }}{{ $unit->actual_name }} @if($unit->base_unit_multiplier) (1 = {{ $unit->base_unit_multiplier }}) @endif @endforeach @endif Wastage % wastage_percentage) }}"> Sequence sequence_order ?? $index + 1) }}" min="0"> @endforeach Update BOM Cancel @endsection