From 5eb067899bf6f096baaea7a2329e2d65509c1a9c Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 3 Feb 2026 12:32:06 +0530 Subject: [PATCH] Added invoice upload directory creation logic while choosing plant on resource page --- app/Filament/Resources/InvoiceValidationResource.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/InvoiceValidationResource.php b/app/Filament/Resources/InvoiceValidationResource.php index ab2a6c8..c5e8b49 100644 --- a/app/Filament/Resources/InvoiceValidationResource.php +++ b/app/Filament/Resources/InvoiceValidationResource.php @@ -77,7 +77,7 @@ class InvoiceValidationResource extends Resource ->afterStateUpdated(function ($state, callable $set, callable $get) { $plantId = $get('plant_id'); $set('update_invoice', null); - // Ensure `linestop_id` is not cleared + if (! $plantId) { $set('invoice_number', null); $set('serial_number', null); @@ -87,6 +87,11 @@ class InvoiceValidationResource extends Resource return; } else { + $plantCode = Plant::find($plantId)?->code ?? null; + $directory = "uploads/temp/{$plantCode}"; + if (! Storage::disk('local')->exists($directory)) { + Storage::disk('local')->makeDirectory($directory); + } $set('ivPlantError', null); } })