@php use App\Models\Material; $materialOptions = Material::whereNotNull('price') ->whereNot('price', 0) ->get() ->map(function ($material) { return [ 'value' => $material->id, 'label' => $material->name, 'code' => $material->code, 'price' => $material->price, ]; }) ->prepend(['value' => '', 'label' => 'Select Material']) ->toArray(); $contractPeriodOptions = collect(Material::getMaxContractPeriodOptions()) ->map(function ($label, $value) { return [ 'value' => (string) $value, 'label' => $label, ]; }) ->values() // Add this to convert to sequential array ->toArray(); $state = $getState() ?? []; if (is_string($state)) { $state = json_decode($state, true); } if (!is_array($state)) { $state = []; } $state = array_map(function ($item) { return [ 'material_code' => $item['material_code'] ?? '', 'material' => $item['material'] ?? '', 'material_contract_period' => $item['material_contract_period'] ?? '', 'material_percentage' => $item['material_percentage'] ?? 0, 'material_value' => $item['material_value'] ?? 0, 'material_price' => $item['material_price'] ?? 0, 'is_repeated_row' => $item['is_repeated_row'] ?? false, 'user_material_id' => $item['user_material_id'] ?? null, 'material_approved_at' => $item['material_approved_at'] ?? null, ]; }, $state); @endphp
@once @push('scripts') @if (app()->environment('local')) @endif @vite('resources/js/react-components.tsx') @endpush @endonce