rang
rang
FFilament
Created by rang on 8/2/2024 in #❓┊help
Repeater data record didnt appear in relationship
protected function handleRecordCreation(array $data): SupplierRestock
{
dd($data);
// Pick highest number and formating code
$lastNumCode = SupplierRestock::max('num_code');
$num_code = $lastNumCode ? $lastNumCode + 1 : 1;
$newCode = 'SR' . str_pad($num_code, 4, '0', STR_PAD_LEFT);

// New Supplier Restock
$supplierRestock = SupplierRestock::create([
'code' => $newCode,
'num_code' => $num_code,
'supplier_id' => $data['supplier_id'],
'qty_tons' => $data['qty_tons'],
'date' => $data['date'],
]);

// Input each supplier items
foreach ($data['restockItems'] as $item) {
SupplierRestockItem::create([
'supplier_restock_id' => $supplierRestock->id,
'item_id' => $item['item_id'],
'qty' => $item['qty'],
'curr_qty' => $item['qty'],
]);
}

return $supplierRestock;
}
protected function handleRecordCreation(array $data): SupplierRestock
{
dd($data);
// Pick highest number and formating code
$lastNumCode = SupplierRestock::max('num_code');
$num_code = $lastNumCode ? $lastNumCode + 1 : 1;
$newCode = 'SR' . str_pad($num_code, 4, '0', STR_PAD_LEFT);

// New Supplier Restock
$supplierRestock = SupplierRestock::create([
'code' => $newCode,
'num_code' => $num_code,
'supplier_id' => $data['supplier_id'],
'qty_tons' => $data['qty_tons'],
'date' => $data['date'],
]);

// Input each supplier items
foreach ($data['restockItems'] as $item) {
SupplierRestockItem::create([
'supplier_restock_id' => $supplierRestock->id,
'item_id' => $item['item_id'],
'qty' => $item['qty'],
'curr_qty' => $item['qty'],
]);
}

return $supplierRestock;
}
i want to modify the SupplierRestockItem creation manually like this but the relationship() keep giving me undefined array key $data['restockItems']
7 replies