production_order null exception solved

This commit is contained in:
dhanabalan
2025-04-23 21:10:51 +05:30
parent 3d744e8183
commit a4471c3c3b

View File

@@ -302,9 +302,10 @@ class ProductionQuantityResource extends Resource
return $get('item_code'); return $get('item_code');
}) })
->default(function () { ->default(function () {
// Get the latest 'item_id' foreign key from 'production_quantities' table // $latestProductionOrder = ProductionQuantity::latest()->first()->production_order;
$latestProductionOrder = ProductionQuantity::latest()->first()->production_order; // return $latestProductionOrder ?? null;
return $latestProductionOrder ?? null; $latestProduction = ProductionQuantity::latest()->first();
return $latestProduction ? $latestProduction->production_order : null;
}), }),
Forms\Components\TextInput::make('item_code') Forms\Components\TextInput::make('item_code')
->label('Item Code') ->label('Item Code')