From bfcb5f9f0ca8bcccf0dbd543779c1fa8f270cff3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 18 Aug 2026 12:45:40 +0530 Subject: [PATCH] Added work center in alert mail resource page --- .../Resources/AlertMailRuleResource.php | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/app/Filament/Resources/AlertMailRuleResource.php b/app/Filament/Resources/AlertMailRuleResource.php index 09e3ed8..b2d1841 100644 --- a/app/Filament/Resources/AlertMailRuleResource.php +++ b/app/Filament/Resources/AlertMailRuleResource.php @@ -8,6 +8,7 @@ use App\Filament\Resources\AlertMailRuleResource\Pages; use App\Models\AlertMailRule; use App\Models\InvoiceMaster; use App\Models\Plant; +use App\Models\Machine; use Filament\Facades\Filament; use Filament\Forms; use Filament\Forms\Components\Actions\Action; @@ -49,6 +50,25 @@ class AlertMailRuleResource extends Resource ->required(fn ($get) => ! $get('is_active')) ->afterStateUpdated(fn ($state, callable $set) => $state ? $set('is_active', false) : null), // ->options(fn () => Plant::pluck('id', 'name')->toArray()), + Forms\Components\Select::make('machine_id') + ->label('Work Center') + ->options(function (callable $get) { + $plantId = $get('plant'); + + if (!$plantId) { + return []; + } + + return Machine::where('plant_id', $plantId) + ->whereNotNull('work_center') + ->pluck('work_center', 'id') + ->toArray(); + }) + ->searchable() + ->reactive() + ->afterStateUpdated(function (callable $set) { + $set('module', null); + }), Forms\Components\Select::make('module') ->label('Module') ->required() @@ -187,6 +207,11 @@ class AlertMailRuleResource extends Resource return $plants[$state] ?? 'All Plants'; }), + Tables\Columns\TextColumn::make('machine.work_center') + ->label('Work Center') + ->alignCenter() + ->searchable() + ->sortable(), Tables\Columns\TextColumn::make('module') ->label('Module Name') ->alignCenter() @@ -197,14 +222,14 @@ class AlertMailRuleResource extends Resource ->alignCenter() ->searchable() ->sortable(), - Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name') - ->label('Receiving Plant') - ->alignCenter() - ->sortable(), - Tables\Columns\TextColumn::make('invoiceMaster.transport_name') - ->label('Transporter') - ->alignCenter() - ->sortable(), + // Tables\Columns\TextColumn::make('invoiceMaster.receiving_plant_name') + // ->label('Receiving Plant') + // ->alignCenter() + // ->sortable(), + // Tables\Columns\TextColumn::make('invoiceMaster.transport_name') + // ->label('Transporter') + // ->alignCenter() + // ->sortable(), Tables\Columns\TextColumn::make('email') ->label('TO Emails') ->searchable()