From a4471c3c3b9def9943ff25ebd4b5dfa74ad83863 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 23 Apr 2025 21:10:51 +0530 Subject: [PATCH] production_order null exception solved --- app/Filament/Resources/ProductionQuantityResource.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/ProductionQuantityResource.php b/app/Filament/Resources/ProductionQuantityResource.php index f27b3a0..f05a4a8 100644 --- a/app/Filament/Resources/ProductionQuantityResource.php +++ b/app/Filament/Resources/ProductionQuantityResource.php @@ -302,9 +302,10 @@ class ProductionQuantityResource extends Resource return $get('item_code'); }) ->default(function () { - // Get the latest 'item_id' foreign key from 'production_quantities' table - $latestProductionOrder = ProductionQuantity::latest()->first()->production_order; - return $latestProductionOrder ?? null; + // $latestProductionOrder = ProductionQuantity::latest()->first()->production_order; + // return $latestProductionOrder ?? null; + $latestProduction = ProductionQuantity::latest()->first(); + return $latestProduction ? $latestProduction->production_order : null; }), Forms\Components\TextInput::make('item_code') ->label('Item Code')