From 7fcb3ebcb29bb95fea6a563e6fdcb769bdc8491d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 18 Aug 2026 12:43:49 +0530 Subject: [PATCH 1/4] Added machine id column migration file for alert mail rule table --- ...ign_key_machine_id_to_alert_mail_rules.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 database/migrations/2026_08_18_115151_add_foreign_key_machine_id_to_alert_mail_rules.php diff --git a/database/migrations/2026_08_18_115151_add_foreign_key_machine_id_to_alert_mail_rules.php b/database/migrations/2026_08_18_115151_add_foreign_key_machine_id_to_alert_mail_rules.php new file mode 100644 index 0000000..8481efb --- /dev/null +++ b/database/migrations/2026_08_18_115151_add_foreign_key_machine_id_to_alert_mail_rules.php @@ -0,0 +1,33 @@ + Date: Tue, 18 Aug 2026 12:44:25 +0530 Subject: [PATCH 2/4] Added machine_id column in alert mail model file --- app/Models/AlertMailRule.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Models/AlertMailRule.php b/app/Models/AlertMailRule.php index be6c00a..9e0212c 100644 --- a/app/Models/AlertMailRule.php +++ b/app/Models/AlertMailRule.php @@ -18,6 +18,7 @@ class AlertMailRule extends Model 'email', 'cc_emails', 'schedule_type', + 'machine_id', 'created_at', 'updated_at', 'created_by', @@ -29,4 +30,10 @@ class AlertMailRule extends Model return $this->belongsTo(InvoiceMaster::class); //return $this->belongsTo(InvoiceMaster::class, 'invoice_master_id'); } + + public function machine(): BelongsTo + { + return $this->belongsTo(Machine::class); + //return $this->belongsTo(InvoiceMaster::class, 'invoice_master_id'); + } } From bfcb5f9f0ca8bcccf0dbd543779c1fa8f270cff3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 18 Aug 2026 12:45:40 +0530 Subject: [PATCH 3/4] 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() From f7964dca258eea2d241474fd3fd923ce035d95ef Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 18 Aug 2026 12:46:24 +0530 Subject: [PATCH 4/4] Added work center column in alert mail exporter --- app/Filament/Exports/AlertMailRuleExporter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Filament/Exports/AlertMailRuleExporter.php b/app/Filament/Exports/AlertMailRuleExporter.php index a3e9a67..52fd383 100644 --- a/app/Filament/Exports/AlertMailRuleExporter.php +++ b/app/Filament/Exports/AlertMailRuleExporter.php @@ -41,6 +41,8 @@ class AlertMailRuleExporter extends Exporter $plant = Plant::find($state); return $plant ? $plant->code : 'Unknown'; }), + ExportColumn::make('machine.work_center') + ->label('WORK CENTER'), ExportColumn::make('cc_emails') ->label('CC EMAILS'), ExportColumn::make('invoiceMaster.receiving_plant_name')