From 7bfdb26089c94c756d958d93ca3dbb82150ed244 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:19:33 +0530 Subject: [PATCH 1/9] Updated navigationsort order on class characteristic resource file --- app/Filament/Resources/ClassCharacteristicResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Filament/Resources/ClassCharacteristicResource.php b/app/Filament/Resources/ClassCharacteristicResource.php index 21c7e24..c8ebbc2 100644 --- a/app/Filament/Resources/ClassCharacteristicResource.php +++ b/app/Filament/Resources/ClassCharacteristicResource.php @@ -36,7 +36,7 @@ class ClassCharacteristicResource extends Resource protected static ?string $navigationGroup = 'Laser Marking'; - protected static ?int $navigationSort = 5; + protected static ?int $navigationSort = 7; public static function form(Form $form): Form { -- 2.49.1 From 1fe0d29fef2eb9fc83801072a0145713b65c9ed3 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:23:19 +0530 Subject: [PATCH 2/9] Added model masters migration file --- ...7_06_161149_create_model_masters_table.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 database/migrations/2026_07_06_161149_create_model_masters_table.php diff --git a/database/migrations/2026_07_06_161149_create_model_masters_table.php b/database/migrations/2026_07_06_161149_create_model_masters_table.php new file mode 100644 index 0000000..c3ac2c9 --- /dev/null +++ b/database/migrations/2026_07_06_161149_create_model_masters_table.php @@ -0,0 +1,58 @@ +id(); + // $table->timestamps(); + // }); + $sql = <<<'SQL' + CREATE TABLE model_masters ( + id BIGINT GENERATED always AS IDENTITY PRIMARY KEY, + plant_id BIGINT NOT NULL, + machine_id BIGINT NOT NULL, + heading_name TEXT DEFAULT NULL, + heading_value TEXT DEFAULT NULL, + type_name TEXT DEFAULT NULL, + type_value TEXT DEFAULT NULL, + has_motor TEXT DEFAULT '0', + has_m_part TEXT DEFAULT '0', + has_m_count TEXT DEFAULT '0', + has_pump TEXT DEFAULT '0', + has_p_part TEXT DEFAULT '0', + has_p_count TEXT DEFAULT '0', + has_name_plate TEXT DEFAULT '0', + has_np_part TEXT DEFAULT '0', + has_np_count TEXT DEFAULT '0', + + created_at TIMESTAMP NOT NULL DEFAULT NOW(), + updated_at TIMESTAMP NOT NULL DEFAULT NOW(), + created_by TEXT DEFAULT NULL, + updated_by TEXT DEFAULT NULL, + deleted_at TIMESTAMP, + + UNIQUE (plant_id, machine_id, heading_name, heading_value, type_name, type_value), + FOREIGN KEY (plant_id) REFERENCES plants (id), + FOREIGN KEY (machine_id) REFERENCES machines (id) + ); + SQL; + + DB::statement($sql); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('model_masters'); + } +}; -- 2.49.1 From 107b3a983ea73d6d549101a62b379cdff269ab9a Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:25:50 +0530 Subject: [PATCH 3/9] Added model masters policies and model file --- app/Models/ModelMaster.php | 46 +++++++++++++ app/Policies/ModelMasterPolicy.php | 106 +++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 app/Models/ModelMaster.php create mode 100644 app/Policies/ModelMasterPolicy.php diff --git a/app/Models/ModelMaster.php b/app/Models/ModelMaster.php new file mode 100644 index 0000000..3b5d0ee --- /dev/null +++ b/app/Models/ModelMaster.php @@ -0,0 +1,46 @@ +belongsTo(Plant::class); + } + + public function machine(): BelongsTo + { + return $this->belongsTo(Machine::class); + } +} diff --git a/app/Policies/ModelMasterPolicy.php b/app/Policies/ModelMasterPolicy.php new file mode 100644 index 0000000..02cd1a3 --- /dev/null +++ b/app/Policies/ModelMasterPolicy.php @@ -0,0 +1,106 @@ +checkPermissionTo('view-any ModelMaster'); + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('view ModelMaster'); + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->checkPermissionTo('create ModelMaster'); + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('update ModelMaster'); + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('delete ModelMaster'); + } + + /** + * Determine whether the user can delete any models. + */ + public function deleteAny(User $user): bool + { + return $user->checkPermissionTo('delete-any ModelMaster'); + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('restore ModelMaster'); + } + + /** + * Determine whether the user can restore any models. + */ + public function restoreAny(User $user): bool + { + return $user->checkPermissionTo('restore-any ModelMaster'); + } + + /** + * Determine whether the user can replicate the model. + */ + public function replicate(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('replicate ModelMaster'); + } + + /** + * Determine whether the user can reorder the models. + */ + public function reorder(User $user): bool + { + return $user->checkPermissionTo('reorder ModelMaster'); + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, ModelMaster $modelmaster): bool + { + return $user->checkPermissionTo('force-delete ModelMaster'); + } + + /** + * Determine whether the user can permanently delete any models. + */ + public function forceDeleteAny(User $user): bool + { + return $user->checkPermissionTo('force-delete-any ModelMaster'); + } +} -- 2.49.1 From f6f73edb5f854311b5ff1303dcd52cceeb7c1633 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:29:20 +0530 Subject: [PATCH 4/9] Added model masters model files for hasMany relations --- app/Models/Machine.php | 5 +++++ app/Models/Plant.php | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Models/Machine.php b/app/Models/Machine.php index 4caf091..f584c02 100644 --- a/app/Models/Machine.php +++ b/app/Models/Machine.php @@ -48,6 +48,11 @@ class Machine extends Model return $this->hasMany(ClassCharacteristic::class, 'machine_id', 'id'); } + public function ModelMasters() + { + return $this->hasMany(ModelMaster::class, 'machine_id', 'id'); + } + public function windedSerialValidationErrors() { return $this->hasMany(WindedSerialValidationError::class, 'machine_id', 'id'); diff --git a/app/Models/Plant.php b/app/Models/Plant.php index 58a6ed0..bc94564 100644 --- a/app/Models/Plant.php +++ b/app/Models/Plant.php @@ -164,10 +164,10 @@ class Plant extends Model return $this->hasMany(ClassCharacteristic::class, 'plant_id', 'id'); } - // public function ModelMasters() - // { - // return $this->hasMany(ModelMaster::class, 'plant_id', 'id'); - // } + public function ModelMasters() + { + return $this->hasMany(ModelMaster::class, 'plant_id', 'id'); + } public function windedSerialValidationErrors() { -- 2.49.1 From b5d6207e7e31580ca68a3e450acde407a3c6bbd8 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:31:07 +0530 Subject: [PATCH 5/9] Added model masters importer and exporter files --- ...TempStopCharacteristicResourceExporter.php | 79 ++++++++++++ ...TempStopCharacteristicResourceImporter.php | 115 ++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 app/Filament/Exports/TempStopCharacteristicResourceExporter.php create mode 100644 app/Filament/Imports/TempStopCharacteristicResourceImporter.php diff --git a/app/Filament/Exports/TempStopCharacteristicResourceExporter.php b/app/Filament/Exports/TempStopCharacteristicResourceExporter.php new file mode 100644 index 0000000..d8a8ea4 --- /dev/null +++ b/app/Filament/Exports/TempStopCharacteristicResourceExporter.php @@ -0,0 +1,79 @@ +label('ID'), + ExportColumn::make('no') + ->label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT CODE'), + ExportColumn::make('machine.work_center') + ->label('WORK CENTER'), + ExportColumn::make('machine_name') + ->label('MACHINE NAME'), + ExportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID'), + ExportColumn::make('item.code') + ->label('ITEM CODE'), + ExportColumn::make('aufnr') + ->label('JOB NUMBER'), + ExportColumn::make('gernr') + ->label('SERIAL NUMBER'), + ExportColumn::make('zmm_heading') + ->label('ZMM HEADING'), + ExportColumn::make('winded_serial_number') + ->label('WINDED SERIAL NUMBER'), + ExportColumn::make('model_type') + ->label('MODEL TYPE'), + ExportColumn::make('characteristic_field') + ->label('MASTER CHARACTERISTIC FIELD'), + ExportColumn::make('samlight_logged_name') + ->label('SAMLIGHT LOGGED NAME'), + ExportColumn::make('stopped_at') + ->label('STOPPED AT'), + ExportColumn::make('stopped_by') + ->label('STOPPED BY'), + ExportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('updated_by') + ->label('UPDATED BY'), + ExportColumn::make('deleted_at') + ->enabledByDefault(false) + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your temp stop characteristic resource export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/TempStopCharacteristicResourceImporter.php b/app/Filament/Imports/TempStopCharacteristicResourceImporter.php new file mode 100644 index 0000000..0c15612 --- /dev/null +++ b/app/Filament/Imports/TempStopCharacteristicResourceImporter.php @@ -0,0 +1,115 @@ +requiredMapping() + ->label('PLANT CODE') + ->exampleHeader('PLANT CODE') + ->example('1000') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('machine') + ->requiredMapping() + ->label('WORK CENTER') + ->exampleHeader('WORK CENTER') + ->example('RMGLAS01') + ->relationship(resolveUsing: 'work_center') + ->rules(['required']), + ImportColumn::make('machine_name') + ->label('MACHINE NAME') + ->exampleHeader('MACHINE NAME') + ->example('RMGLAS01') + ->rules(['required']), + ImportColumn::make('item') + ->requiredMapping() + ->exampleHeader('ITEM CODE') + ->example('630214') + ->label('ITEM CODE') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('aufnr') + ->label('JOB NUMBER') + ->exampleHeader('JOB NUMBER') + ->example('1234567'), + ImportColumn::make('gernr') + ->label('SERIAL NUMBER') + ->exampleHeader('SERIAL NUMBER') + ->example('1234567890123'), + ImportColumn::make('zmm_heading') + ->exampleHeader('ZMM HEADING') + ->example('ZMM001') + ->label('ZMM HEADING'), + ImportColumn::make('winded_serial_number') + ->exampleHeader('WINDED SERIAL NUMBER') + ->example('WSN001') + ->label('WINDED SERIAL NUMBER'), + ImportColumn::make('model_type') + ->label('MODEL TYPE') + ->exampleHeader('MODEL TYPE') + ->example('PUMP'), + ImportColumn::make('characteristic_field') + ->label('MASTER CHARACTERISTIC FIELD') + ->exampleHeader('MASTER CHARACTERISTIC FIELD') + ->example('NIL'), + ImportColumn::make('samlight_logged_name') + ->label('SAMLIGHT LOGGED NAME') + ->exampleHeader('SAMLIGHT LOGGED NAME') + ->example('User'), + ImportColumn::make('stopped_at') + ->label('STOPPED AT') + ->exampleHeader('STOPPED AT') + ->example('01-09-2026 12:00:00') + ->rules(['datetime']), + ImportColumn::make('stopped_by') + ->label('STOPPED BY') + ->exampleHeader('STOPPED BY') + ->example('RAW01234'), + ImportColumn::make('has_stop_flow_id') + ->label('HAS STOP FLOW ID') + ->exampleHeader('HAS STOP FLOW ID') + ->example('2'), + ImportColumn::make('created_by') + ->label('CREATED BY') + ->exampleHeader('CREATED BY') + ->example('RAW01234'), + ImportColumn::make('updated_by') + ->label('UPDATED BY') + ->exampleHeader('UPDATED BY') + ->example('RAW01234'), + ]; + } + + public function resolveRecord(): ?TempStopCharacteristicResource + { + // return TempStopCharacteristicResource::firstOrNew([ + // // Update existing records, matching them by `$this->data['column_name']` + // 'email' => $this->data['email'], + // ]); + + return new TempStopCharacteristicResource; + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your temp stop characteristic resource import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; + } + + return $body; + } +} -- 2.49.1 From e0437d11f2c6de72d955703270ed0049ee8d5f1b Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:50:43 +0530 Subject: [PATCH 6/9] Removed importer and exporter file as not need --- ...TempStopCharacteristicResourceExporter.php | 79 ------------ ...TempStopCharacteristicResourceImporter.php | 115 ------------------ 2 files changed, 194 deletions(-) delete mode 100644 app/Filament/Exports/TempStopCharacteristicResourceExporter.php delete mode 100644 app/Filament/Imports/TempStopCharacteristicResourceImporter.php diff --git a/app/Filament/Exports/TempStopCharacteristicResourceExporter.php b/app/Filament/Exports/TempStopCharacteristicResourceExporter.php deleted file mode 100644 index d8a8ea4..0000000 --- a/app/Filament/Exports/TempStopCharacteristicResourceExporter.php +++ /dev/null @@ -1,79 +0,0 @@ -label('ID'), - ExportColumn::make('no') - ->label('NO') - ->state(function ($record) use (&$rowNumber) { - // Increment and return the row number - return ++$rowNumber; - }), - ExportColumn::make('plant.code') - ->label('PLANT CODE'), - ExportColumn::make('machine.work_center') - ->label('WORK CENTER'), - ExportColumn::make('machine_name') - ->label('MACHINE NAME'), - ExportColumn::make('has_stop_flow_id') - ->label('HAS STOP FLOW ID'), - ExportColumn::make('item.code') - ->label('ITEM CODE'), - ExportColumn::make('aufnr') - ->label('JOB NUMBER'), - ExportColumn::make('gernr') - ->label('SERIAL NUMBER'), - ExportColumn::make('zmm_heading') - ->label('ZMM HEADING'), - ExportColumn::make('winded_serial_number') - ->label('WINDED SERIAL NUMBER'), - ExportColumn::make('model_type') - ->label('MODEL TYPE'), - ExportColumn::make('characteristic_field') - ->label('MASTER CHARACTERISTIC FIELD'), - ExportColumn::make('samlight_logged_name') - ->label('SAMLIGHT LOGGED NAME'), - ExportColumn::make('stopped_at') - ->label('STOPPED AT'), - ExportColumn::make('stopped_by') - ->label('STOPPED BY'), - ExportColumn::make('has_stop_flow_id') - ->label('HAS STOP FLOW ID'), - ExportColumn::make('created_at') - ->label('CREATED AT'), - ExportColumn::make('created_by') - ->label('CREATED BY'), - ExportColumn::make('updated_at') - ->label('UPDATED AT'), - ExportColumn::make('updated_by') - ->label('UPDATED BY'), - ExportColumn::make('deleted_at') - ->enabledByDefault(false) - ->label('DELETED AT'), - ]; - } - - public static function getCompletedNotificationBody(Export $export): string - { - $body = 'Your temp stop characteristic resource export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; - - if ($failedRowsCount = $export->getFailedRowsCount()) { - $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; - } - - return $body; - } -} diff --git a/app/Filament/Imports/TempStopCharacteristicResourceImporter.php b/app/Filament/Imports/TempStopCharacteristicResourceImporter.php deleted file mode 100644 index 0c15612..0000000 --- a/app/Filament/Imports/TempStopCharacteristicResourceImporter.php +++ /dev/null @@ -1,115 +0,0 @@ -requiredMapping() - ->label('PLANT CODE') - ->exampleHeader('PLANT CODE') - ->example('1000') - ->relationship(resolveUsing: 'code') - ->rules(['required']), - ImportColumn::make('machine') - ->requiredMapping() - ->label('WORK CENTER') - ->exampleHeader('WORK CENTER') - ->example('RMGLAS01') - ->relationship(resolveUsing: 'work_center') - ->rules(['required']), - ImportColumn::make('machine_name') - ->label('MACHINE NAME') - ->exampleHeader('MACHINE NAME') - ->example('RMGLAS01') - ->rules(['required']), - ImportColumn::make('item') - ->requiredMapping() - ->exampleHeader('ITEM CODE') - ->example('630214') - ->label('ITEM CODE') - ->relationship(resolveUsing: 'code') - ->rules(['required']), - ImportColumn::make('aufnr') - ->label('JOB NUMBER') - ->exampleHeader('JOB NUMBER') - ->example('1234567'), - ImportColumn::make('gernr') - ->label('SERIAL NUMBER') - ->exampleHeader('SERIAL NUMBER') - ->example('1234567890123'), - ImportColumn::make('zmm_heading') - ->exampleHeader('ZMM HEADING') - ->example('ZMM001') - ->label('ZMM HEADING'), - ImportColumn::make('winded_serial_number') - ->exampleHeader('WINDED SERIAL NUMBER') - ->example('WSN001') - ->label('WINDED SERIAL NUMBER'), - ImportColumn::make('model_type') - ->label('MODEL TYPE') - ->exampleHeader('MODEL TYPE') - ->example('PUMP'), - ImportColumn::make('characteristic_field') - ->label('MASTER CHARACTERISTIC FIELD') - ->exampleHeader('MASTER CHARACTERISTIC FIELD') - ->example('NIL'), - ImportColumn::make('samlight_logged_name') - ->label('SAMLIGHT LOGGED NAME') - ->exampleHeader('SAMLIGHT LOGGED NAME') - ->example('User'), - ImportColumn::make('stopped_at') - ->label('STOPPED AT') - ->exampleHeader('STOPPED AT') - ->example('01-09-2026 12:00:00') - ->rules(['datetime']), - ImportColumn::make('stopped_by') - ->label('STOPPED BY') - ->exampleHeader('STOPPED BY') - ->example('RAW01234'), - ImportColumn::make('has_stop_flow_id') - ->label('HAS STOP FLOW ID') - ->exampleHeader('HAS STOP FLOW ID') - ->example('2'), - ImportColumn::make('created_by') - ->label('CREATED BY') - ->exampleHeader('CREATED BY') - ->example('RAW01234'), - ImportColumn::make('updated_by') - ->label('UPDATED BY') - ->exampleHeader('UPDATED BY') - ->example('RAW01234'), - ]; - } - - public function resolveRecord(): ?TempStopCharacteristicResource - { - // return TempStopCharacteristicResource::firstOrNew([ - // // Update existing records, matching them by `$this->data['column_name']` - // 'email' => $this->data['email'], - // ]); - - return new TempStopCharacteristicResource; - } - - public static function getCompletedNotificationBody(Import $import): string - { - $body = 'Your temp stop characteristic resource import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; - - if ($failedRowsCount = $import->getFailedRowsCount()) { - $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; - } - - return $body; - } -} -- 2.49.1 From f896b76ba8cacd9714f3411ae837b33810293d0d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 10:52:39 +0530 Subject: [PATCH 7/9] Added model masters resources, importer, and exporter files --- app/Filament/Exports/ModelMasterExporter.php | 79 ++++ app/Filament/Imports/ModelMasterImporter.php | 249 +++++++++++ .../Resources/ModelMasterResource.php | 394 ++++++++++++++++++ .../Pages/CreateModelMaster.php | 12 + .../Pages/EditModelMaster.php | 22 + .../Pages/ListModelMasters.php | 19 + .../Pages/ViewModelMaster.php | 19 + 7 files changed, 794 insertions(+) create mode 100644 app/Filament/Exports/ModelMasterExporter.php create mode 100644 app/Filament/Imports/ModelMasterImporter.php create mode 100644 app/Filament/Resources/ModelMasterResource.php create mode 100644 app/Filament/Resources/ModelMasterResource/Pages/CreateModelMaster.php create mode 100644 app/Filament/Resources/ModelMasterResource/Pages/EditModelMaster.php create mode 100644 app/Filament/Resources/ModelMasterResource/Pages/ListModelMasters.php create mode 100644 app/Filament/Resources/ModelMasterResource/Pages/ViewModelMaster.php diff --git a/app/Filament/Exports/ModelMasterExporter.php b/app/Filament/Exports/ModelMasterExporter.php new file mode 100644 index 0000000..4988b7d --- /dev/null +++ b/app/Filament/Exports/ModelMasterExporter.php @@ -0,0 +1,79 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('plant.code') + ->label('PLANT CODE'), + ExportColumn::make('machine.work_center') + ->label('WORK CENTER'), + ExportColumn::make('heading_name') + ->label('HEADING NAME'), + ExportColumn::make('heading_value') + ->label('HEADING VALUE'), + ExportColumn::make('type_name') + ->label('TYPE NAME'), + ExportColumn::make('type_value') + ->label('TYPE VALUE'), + ExportColumn::make('has_motor') + ->label('HAS MOTOR'), + ExportColumn::make('has_m_part') + ->label('HAS MOTOR PART'), + ExportColumn::make('has_m_count') + ->label('HAS MOTOR COUNT'), + ExportColumn::make('has_pump') + ->label('HAS PUMP'), + ExportColumn::make('has_p_part') + ->label('HAS PUMP PART'), + ExportColumn::make('has_p_count') + ->label('HAS PUMP COUNT'), + ExportColumn::make('has_name_plate') + ->label('HAS NAME PLATE'), + ExportColumn::make('has_np_part') + ->label('HAS NAME PLATE PART'), + ExportColumn::make('has_np_count') + ->label('HAS NAME PLATE COUNT'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_at') + ->label('UPDATED AT') + ->enabledByDefault(true), + ExportColumn::make('updated_by') + ->label('UPDATED BY') + ->enabledByDefault(true), + ExportColumn::make('deleted_at') + ->label('DELETED AT') + ->enabledByDefault(false), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your model master export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Imports/ModelMasterImporter.php b/app/Filament/Imports/ModelMasterImporter.php new file mode 100644 index 0000000..4986680 --- /dev/null +++ b/app/Filament/Imports/ModelMasterImporter.php @@ -0,0 +1,249 @@ +label('PLANT CODE') + ->requiredMapping() + ->exampleHeader('PLANT CODE') + ->example('1000') + ->relationship(resolveUsing: 'code') + ->rules(['required']), + ImportColumn::make('machine') + ->label('WORK CENTER') + ->requiredMapping() + ->exampleHeader('WORK CENTER') + ->example('RMGLAS01') + ->relationship(resolveUsing: 'work_center') + ->rules(['required']), + ImportColumn::make('heading_name') + ->label('HEADING NAME') + ->exampleHeader('HEADING NAME') + ->example('ZMM_HEADING'), + ImportColumn::make('heading_value') + ->label('HEADING VALUE') + ->exampleHeader('HEADING VALUE') + ->example('PUMPS'), + ImportColumn::make('type_name') + ->label('TYPE NAME') + ->exampleHeader('TYPE NAME') + ->example(''), + ImportColumn::make('type_value') + ->label('TYPE VALUE') + ->exampleHeader('TYPE VALUE') + ->example(''), + ImportColumn::make('has_motor') + ->label('HAS MOTOR') + ->exampleHeader('HAS MOTOR') + ->example('1'), + ImportColumn::make('has_m_part') + ->label('HAS MOTOR PART') + ->exampleHeader('HAS MOTOR PART') + ->example('1'), + ImportColumn::make('has_m_count') + ->label('HAS MOTOR COUNT') + ->exampleHeader('HAS MOTOR COUNT') + ->example('1'), + ImportColumn::make('has_pump') + ->label('HAS PUMP') + ->exampleHeader('HAS PUMP') + ->example('1'), + ImportColumn::make('has_p_part') + ->label('HAS PUMP PART') + ->exampleHeader('HAS PUMP PART') + ->example('1'), + ImportColumn::make('has_p_count') + ->label('HAS PUMP COUNT') + ->exampleHeader('HAS PUMP COUNT') + ->example('1'), + ImportColumn::make('has_name_plate') + ->label('HAS NAME PLATE') + ->exampleHeader('HAS NAME PLATE') + ->example(''), + ImportColumn::make('has_np_part') + ->label('HAS NAME PLATE PART') + ->exampleHeader('HAS NAME PLATE PART') + ->example(''), + ImportColumn::make('has_np_count') + ->label('HAS NAME PLATE COUNT') + ->exampleHeader('HAS NAME PLATE COUNT') + ->example(''), + ]; + } + + public function resolveRecord(): ?ModelMaster + { + $warnMsg = []; + $plantCod = trim($this->data['plant']); + $plant = null; + $plantId = null; + $workCent = trim($this->data['machine']); + $machine = null; + $machineId = null; + $headingName = strtoupper(trim($this->data['heading_name'])); + $headingValue = strtoupper(trim($this->data['heading_value'])); + $typeName = strtoupper(trim($this->data['type_name'])); + $typeValue = (Str::length($typeName) <= 0) ? '' : strtoupper(trim($this->data['type_value'])); + $hasMotor = (trim($this->data['has_motor']) == '1') ? '1' : '0'; + $hasMPart = (trim($this->data['has_m_part']) == '1') ? '1' : '0'; + $hasMCount = ($hasMotor == '1') ? trim($this->data['has_m_count']) : '0'; + $hasPump = (trim($this->data['has_pump']) == '1') ? '1' : '0'; + $hasPPart = (trim($this->data['has_p_part']) == '1') ? '1' : '0'; + $hasPCount = ($hasPump == '1') ? trim($this->data['has_p_count']) : '0'; + $hasNamePlate = (trim($this->data['has_name_plate']) == '1') ? '1' : '0'; + $hasNpPart = (trim($this->data['has_np_part']) == '1') ? '1' : '0'; + $hasNpCount = ($hasNamePlate == '1') ? trim($this->data['has_np_count']) : '0'; + $createdBy = Filament::auth()->user()->name; + $updatedBy = Filament::auth()->user()->name; + + if ($plantCod == null || $plantCod == '' || ! $plantCod) { + $warnMsg[] = "Plant code can't be empty!"; + } elseif (! is_numeric($plantCod)) { + $warnMsg[] = "Plant code '{$plantCod}' should contain only numeric values!"; + } elseif (Str::length($plantCod) < 4 || Str::length($plantCod) > 7) { + $warnMsg[] = "Plant code '{$plantCod}' must be between 4 and 7 digits only!"; + } elseif (! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) { + $warnMsg[] = "Invalid plant code '{$plantCod}' found!"; + } + + if ($workCent == null || $workCent == '' || ! $workCent) { + $warnMsg[] = "Work center can't be empty!"; + } elseif (Str::length($workCent) < 6) { + $warnMsg[] = "Work center '{$workCent}' should contain minimum 6 characters!"; + } elseif (! ctype_alnum($workCent)) { + $warnMsg[] = "Work center '{$workCent}' should contain only alpha-numeric values!"; + } elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $workCent)) { + $warnMsg[] = "Invalid work center '{$workCent}' found!"; + } + + $columns = Schema::getColumnListing('class_characteristics'); + + if ($headingName == null || $headingName == '' || ! $headingName) { + $warnMsg[] = "Heading name can't be empty!"; + } elseif (Str::length($headingName) < 5) { + $warnMsg[] = "Heading name '{$headingName}' should contain minimum 5 characters!"; + } else { + if (! in_array($headingName, $columns, true)) { + $warnMsg[] = 'Unknown heading name found!'; + } + } + + if ($typeName != null && $typeName != '' && $typeName) { + if (Str::length($typeName) < 5) { + $warnMsg[] = "Type name '{$typeName}' should contain minimum 5 characters!"; + } else { + if (! in_array($typeName, $columns, true)) { + $warnMsg[] = 'Unknown type name found!'; + } + } + } + + if ($hasMotor != '1') { + $hasMPart = '0'; + $hasMCount = '0'; + } else { + $hasMPart = ($hasMPart != '1') ? '0' : '1'; + $hasMCount = ($hasMCount == '0' || empty($hasMCount) || ! is_numeric($hasMCount) || ! preg_match('/^([1-9]|[1-9][0-9])$/', $hasMCount)) ? '1' : $hasMCount; + } + + if ($hasPump != '1') { + $hasPPart = '0'; + $hasPCount = '0'; + } else { + $hasPPart = ($hasPPart != '1') ? '0' : '1'; + $hasPCount = ($hasPCount == '0' || empty($hasPCount) || ! is_numeric($hasPCount) || ! preg_match('/^([1-9]|[1-9][0-9])$/', $hasPCount)) ? '1' : $hasPCount; + } + + if ($hasNamePlate != '1') { + $hasNpPart = '0'; + $hasNpCount = '0'; + } else { + $hasNpPart = ($hasNpPart != '1') ? '0' : '1'; + $hasNpCount = ($hasNpCount == '0' || empty($hasNpCount) || ! is_numeric($hasNpCount) || ! preg_match('/^([1-9]|[1-9][0-9])$/', $hasNpCount)) ? '1' : $hasNpCount; + } + + $plant = Plant::where('code', $plantCod)->first(); + if (! $plant) { + $warnMsg[] = 'Plant code not found!'; + } else { + $plantId = $plant->id; + $machine = Machine::where('work_center', $workCent)->first(); + if (! $machine) { + $warnMsg[] = 'Work center not found!'; + } else { + $machine = Machine::where('work_center', $workCent)->where('plant_id', $plantId)->first(); + if (! $machine) { + $warnMsg[] = 'Work center not found for the plant!'; + } else { + $machineId = $machine->id; + + if (empty($warnMsg)) { + $recExist = ModelMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('heading_name', $headingName)->where('heading_value', $headingValue)->where('type_name', $typeName)->where('type_value', $typeValue)->first()?->created_by; + + if ($recExist) { + $createdBy = $recExist; + } + } + } + } + } + + if (! empty($warnMsg)) { + throw new RowImportFailedException(implode(', ', $warnMsg)); + } + + return ModelMaster::updateOrCreate([ + 'plant_id' => $plantId, + 'machine_id' => $machineId, + 'heading_name' => $headingName, + 'heading_value' => $headingValue, + 'type_name' => $typeName, + 'type_value' => $typeValue, + ], + [ + 'has_motor' => $hasMotor, + 'has_m_part' => $hasMPart, + 'has_m_count' => $hasMCount, + 'has_pump' => $hasPump, + 'has_p_part' => $hasPPart, + 'has_p_count' => $hasPCount, + 'has_name_plate' => $hasNamePlate, + 'has_np_part' => $hasNpPart, + 'has_np_count' => $hasNpCount, + 'created_by' => $createdBy, + 'updated_by' => $updatedBy, + ] + ); + + // return new ModelMaster; + } + + public static function getCompletedNotificationBody(Import $import): string + { + $body = 'Your model master import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.'; + + if ($failedRowsCount = $import->getFailedRowsCount()) { + $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.'; + } + + return $body; + } +} diff --git a/app/Filament/Resources/ModelMasterResource.php b/app/Filament/Resources/ModelMasterResource.php new file mode 100644 index 0000000..480efe9 --- /dev/null +++ b/app/Filament/Resources/ModelMasterResource.php @@ -0,0 +1,394 @@ +schema([ + Forms\Components\Select::make('plant_id') + ->label('PLANT NAME') + ->relationship('plant', 'name') + ->reactive() + ->searchable() + ->options(function (callable $get) { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); + }) + ->disabled(fn (Get $get) => ! empty($get('id'))) + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ModelMaster::latest()->first())->plant_id; + }) + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('machine_id', null); + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\Select::make('machine_id') + ->label('WORK CENTER') + ->reactive() + ->searchable() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (empty($plantId)) { + return []; + } + + return Machine::where('plant_id', $plantId)->orderBy('work_center')->pluck('work_center', 'id')->toArray(); + }) + ->disabled(fn (Get $get) => ! empty($get('id'))) + ->default(function (callable $get) { + $plantId = $get('plant_id'); + if (empty($plantId)) { + return null; + } + + return ModelMaster::where('plant_id', $plantId)->latest()->first()->machine_id ?? null; + }) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('heading_name') + ->label('HEADING NAME') + ->reactive() + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('heading_value') + ->label('HEADING VALUE') + ->reactive() + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('type_name') + ->label('TYPE NAME') + ->reactive() + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('type_value') + ->label('TYPE VALUE') + ->reactive() + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('has_motor') + ->label('HAS MOTOR') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_m_part') + ->label('HAS MOTOR PART') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_m_count') + ->label('HAS MOTOR COUNT') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(99) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_pump') + ->label('HAS PUMP') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_p_part') + ->label('HAS PUMP PART') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_p_count') + ->label('HAS PUMP COUNT') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(99) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_name_plate') + ->label('HAS NAME PLATE') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_np_part') + ->label('HAS NAME PLATE PART') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(1) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\TextInput::make('has_np_count') + ->label('HAS NAME PLATE COUNT') + ->reactive() + ->minValue(0) + ->integer() + ->maxValue(99) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id'))) + ->afterStateUpdated(function (callable $set) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->required(), + Forms\Components\Hidden::make('created_by') + ->label('Created By') + ->default(Filament::auth()->user()?->name), + Forms\Components\Hidden::make('updated_by') + ->label('Updated By') + ->default(Filament::auth()->user()?->name), + Forms\Components\TextInput::make('id') + ->hidden() + ->readOnly(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('No.') + ->label('NO') + ->alignCenter() + ->getStateUsing(function ($record, $livewire, $column, $rowLoop) { + $paginator = $livewire->getTableRecords(); + $perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10; + $currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1; + + return ($currentPage - 1) * $perPage + $rowLoop->iteration; + }), + Tables\Columns\TextColumn::make('plant.name') + ->label('PLANT NAME') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('machine.work_center') + ->label('WORK CENTER') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('heading_name') + ->label('HEADING NAME') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('heading_value') + ->label('HEADING VALUE') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('type_name') + ->label('TYPE NAME') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('type_value') + ->label('TYPE VALUE') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_motor') + ->label('HAS MOTOR') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_m_part') + ->label('HAS MOTOR PART') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_m_count') + ->label('HAS MOTOR COUNT') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_pump') + ->label('HAS PUMP') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_p_part') + ->label('HAS PUMP PART') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_p_count') + ->label('HAS PUMP COUNT') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_name_plate') + ->label('HAS NAME PLATE') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_np_part') + ->label('HAS NAME PLATE PART') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('has_np_count') + ->label('HAS NAME PLATE COUNT') + ->alignCenter() + ->searchable() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->label('CREATED AT') + ->alignCenter() + ->dateTime() + ->sortable(), + Tables\Columns\TextColumn::make('created_by') + ->label('CREATED BY') + ->alignCenter(), + Tables\Columns\TextColumn::make('updated_at') + ->label('UPDATED AT') + ->alignCenter() + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: false), + Tables\Columns\TextColumn::make('updated_by') + ->label('UPDATED BY') + ->alignCenter() + ->toggleable(isToggledHiddenByDefault: false), + Tables\Columns\TextColumn::make('deleted_at') + ->label('DELETED AT') + ->alignCenter() + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + Tables\Filters\TrashedFilter::make(), + ]) + ->actions([ + Tables\Actions\ViewAction::make(), + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + Tables\Actions\ForceDeleteBulkAction::make(), + Tables\Actions\RestoreBulkAction::make(), + ]), + ]) + ->headerActions([ + ImportAction::make() + ->label('Import Model Masters') + ->color('warning') + ->importer(ModelMasterImporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view import model master'); + }), + ExportAction::make() + ->label('Export Model Masters') + ->color('warning') + ->exporter(ModelMasterExporter::class) + ->visible(function () { + return Filament::auth()->user()->can('view export model master'); + }), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListModelMasters::route('/'), + 'create' => Pages\CreateModelMaster::route('/create'), + 'view' => Pages\ViewModelMaster::route('/{record}'), + 'edit' => Pages\EditModelMaster::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/ModelMasterResource/Pages/CreateModelMaster.php b/app/Filament/Resources/ModelMasterResource/Pages/CreateModelMaster.php new file mode 100644 index 0000000..bb125aa --- /dev/null +++ b/app/Filament/Resources/ModelMasterResource/Pages/CreateModelMaster.php @@ -0,0 +1,12 @@ + Date: Sat, 5 Sep 2026 12:13:34 +0530 Subject: [PATCH 8/9] Updated disabled functionality if record exist --- .../RequestCharacteristicResource.php | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/Filament/Resources/RequestCharacteristicResource.php b/app/Filament/Resources/RequestCharacteristicResource.php index 93c9695..63146d4 100644 --- a/app/Filament/Resources/RequestCharacteristicResource.php +++ b/app/Filament/Resources/RequestCharacteristicResource.php @@ -104,7 +104,8 @@ class RequestCharacteristicResource extends Resource } $set('updated_by', Filament::auth()->user()?->name); }) - ->disabled(fn ($get) => self::isFieldDisabled($get)), + // ->disabled(fn ($get) => self::isFieldDisabled($get)) + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\Select::make('machine_id') ->label('Work Center') // ->relationship('machine', 'name') @@ -133,7 +134,7 @@ class RequestCharacteristicResource extends Resource $set('approver_type', null); $set('updated_by', Filament::auth()->user()?->name); }) - ->disabled(fn ($get) => self::isFieldDisabled($get)), + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\Hidden::make('show_validation_image') ->reactive() ->default(false), @@ -224,7 +225,7 @@ class RequestCharacteristicResource extends Resource return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->item_id ?? null; }) - ->disabled(fn ($get) => self::isFieldDisabled($get)), + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('aufnr') ->label('Job Number') ->reactive() @@ -251,7 +252,7 @@ class RequestCharacteristicResource extends Resource return ($userHas && strlen($userHas) > 0) ? null : optional(RequestCharacteristic::latest()->first())->aufnr ?? null; }) ->readOnly(fn ($get) => ($get('item_id') == null)) - ->disabled(fn ($get) => self::isFieldDisabled($get)), + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('gernr') ->label('Serial Number') ->reactive() @@ -281,7 +282,8 @@ class RequestCharacteristicResource extends Resource } return false; - }), + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\Select::make('machine_name') ->label('Machine Name') ->reactive() @@ -334,7 +336,8 @@ class RequestCharacteristicResource extends Resource } } }) - ->required(), + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\Select::make('approver_type') ->label('Request Type') // ->columnSpan(1) @@ -400,7 +403,8 @@ class RequestCharacteristicResource extends Resource $set('approver_type', null); } } - }), + }) + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\Select::make('characteristic_approver_master_id') ->label('Master Characteristic Field') // ->relationship('characteristicApproverMaster', 'characteristic_field') @@ -431,7 +435,8 @@ class RequestCharacteristicResource extends Resource $set('update_value', null); $set('updated_by', Filament::auth()->user()?->name); }) - ->required(), + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('model_type') ->label('Model Type') ->reactive() @@ -442,8 +447,8 @@ class RequestCharacteristicResource extends Resource $set('update_value', null); $set('updated_by', Filament::auth()->user()?->name); }) - ->required(), - // ->disabled(fn ($get) => self::isFieldDisabled($get)) + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), Section::make('Request Characteristic Details') // ->columnSpan(['default' => 2, 'sm' => 4]) ->reactive() -- 2.49.1 From fb7af88a34ce16fae292a52b556286054a9d9576 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 5 Sep 2026 16:11:38 +0530 Subject: [PATCH 9/9] Added supplier number in panel box report --- app/Console/Commands/SendPanelBoxReport.php | 10 ++++++++++ resources/views/mail/panel-box-report.blade.php | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/app/Console/Commands/SendPanelBoxReport.php b/app/Console/Commands/SendPanelBoxReport.php index 115007e..94e66f9 100644 --- a/app/Console/Commands/SendPanelBoxReport.php +++ b/app/Console/Commands/SendPanelBoxReport.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Mail\PanelBoxReportMail; use App\Models\Machine; +use App\Models\PanelBoxValidation; use App\Models\Plant; use App\Models\ProductionCharacteristic; use Illuminate\Console\Command; @@ -94,6 +95,15 @@ class SendPanelBoxReport extends Command ->distinct() ->get(); + foreach ($records as $record) { + + $supplierNumber = PanelBoxValidation::where('plant_id', $plantId) + ->where('serial_number', $record->serial_number) + ->first()?->panel_box_supplier; + + $record->panel_box_supplier = $supplierNumber; + } + if ($records->isEmpty()) { $this->info('No panel box records found.'); return; diff --git a/resources/views/mail/panel-box-report.blade.php b/resources/views/mail/panel-box-report.blade.php index b4111f5..4a06e26 100644 --- a/resources/views/mail/panel-box-report.blade.php +++ b/resources/views/mail/panel-box-report.blade.php @@ -264,6 +264,7 @@ S.No + Supplier Number Serial Number Status @@ -279,6 +280,12 @@ {{ $index + 1 }} + + + {{ $record->panel_box_supplier }} + + + {{ $record->serial_number }} -- 2.49.1