From a5036b7d6f27bc369efefff592a6070726a82ca0 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 18 Jul 2025 18:05:27 +0530 Subject: [PATCH] Added temp live reading resource files --- .../Resources/TempLiveReadingResource.php | 134 ++++++++++++++++++ .../Pages/CreateTempLiveReading.php | 12 ++ .../Pages/EditTempLiveReading.php | 22 +++ .../Pages/ListTempLiveReadings.php | 19 +++ .../Pages/ViewTempLiveReading.php | 19 +++ 5 files changed, 206 insertions(+) create mode 100644 app/Filament/Resources/TempLiveReadingResource.php create mode 100644 app/Filament/Resources/TempLiveReadingResource/Pages/CreateTempLiveReading.php create mode 100644 app/Filament/Resources/TempLiveReadingResource/Pages/EditTempLiveReading.php create mode 100644 app/Filament/Resources/TempLiveReadingResource/Pages/ListTempLiveReadings.php create mode 100644 app/Filament/Resources/TempLiveReadingResource/Pages/ViewTempLiveReading.php diff --git a/app/Filament/Resources/TempLiveReadingResource.php b/app/Filament/Resources/TempLiveReadingResource.php new file mode 100644 index 000000000..129817283 --- /dev/null +++ b/app/Filament/Resources/TempLiveReadingResource.php @@ -0,0 +1,134 @@ +schema([ + Section::make('') + ->schema([ + Forms\Components\Select::make('plant_id') + ->label('Plant') + ->relationship('plant', 'name') + ->reactive() + ->required(), + Forms\Components\Select::make('mfm_meter_id') + ->label('MFM Meter ID') + ->required() + ->reactive() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (!$plantId) { + return []; + } + + return MfmMeter::where('plant_id', $plantId) + ->pluck('sequence', 'id') + ->toArray(); + }), + Forms\Components\TextInput::make('register_data') + ->label('Register Data') + ->required(), + Forms\Components\Hidden::make('created_by') + ->default(Filament::auth()->user()?->name), + ]) + ->columns(3), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id') + ->label('ID') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('plant.name') + ->numeric() + ->sortable(), + // Tables\Columns\TextColumn::make('mfm_meter_id.sequence') + // ->label('Sequence') + // ->sortable(), + Tables\Columns\TextColumn::make('mfmMeter.name') + ->label('Name') + ->sortable(), + Tables\Columns\TextColumn::make('register_data') + ->label('Register Data') + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('updated_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('deleted_at') + ->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(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ListTempLiveReadings::route('/'), + 'create' => Pages\CreateTempLiveReading::route('/create'), + 'view' => Pages\ViewTempLiveReading::route('/{record}'), + 'edit' => Pages\EditTempLiveReading::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/TempLiveReadingResource/Pages/CreateTempLiveReading.php b/app/Filament/Resources/TempLiveReadingResource/Pages/CreateTempLiveReading.php new file mode 100644 index 000000000..68da71367 --- /dev/null +++ b/app/Filament/Resources/TempLiveReadingResource/Pages/CreateTempLiveReading.php @@ -0,0 +1,12 @@ +