Updated alignments and added orderby query while load plant
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-02-10 12:45:54 +05:30
parent 6c9408663b
commit aaa9c17e66
36 changed files with 1592 additions and 1574 deletions

View File

@@ -5,28 +5,27 @@ namespace App\Filament\Resources;
use App\Filament\Exports\TempLiveReadingExporter;
use App\Filament\Imports\TempLiveReadingImporter;
use App\Filament\Resources\TempLiveReadingResource\Pages;
use App\Filament\Resources\TempLiveReadingResource\RelationManagers;
use App\Models\MfmMeter;
use App\Models\Plant;
use App\Models\TempLiveReading;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\Section;
use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Actions\ExportAction;
class TempLiveReadingResource extends Resource
{
protected static ?string $model = TempLiveReading::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Power House';
public static function form(Form $form): Form
@@ -34,37 +33,38 @@ class TempLiveReadingResource extends Resource
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
}),
Forms\Components\Select::make('mfm_meter_id')
->label('MFM Meter ID')
->required()
->reactive()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (!$plantId) {
return [];
}
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
->required()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
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),
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
}),
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),
->columns(3),
]);
}
@@ -78,6 +78,7 @@ class TempLiveReadingResource extends Resource
$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')
@@ -119,18 +120,18 @@ class TempLiveReadingResource extends Resource
Tables\Actions\RestoreBulkAction::make(),
]),
]);
// ->headerActions([
// ImportAction::make()
// ->importer(TempLiveReadingImporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view import temp live reading');
// }),
// ExportAction::make()
// ->exporter(TempLiveReadingExporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view export temp live reading');
// }),
// ]);
// ->headerActions([
// ImportAction::make()
// ->importer(TempLiveReadingImporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view import temp live reading');
// }),
// ExportAction::make()
// ->exporter(TempLiveReadingExporter::class)
// ->visible(function() {
// return Filament::auth()->user()->can('view export temp live reading');
// }),
// ]);
}
public static function getRelations(): array
@@ -139,6 +140,7 @@ class TempLiveReadingResource extends Resource
//
];
}
public static function getNavigationLabel(): string
{
return 'Live Readings';
@@ -149,7 +151,6 @@ class TempLiveReadingResource extends Resource
return 'Live Readings';
}
public static function getPages(): array
{
return [