diff --git a/app/Filament/Resources/ConfigurationResource.php b/app/Filament/Resources/ConfigurationResource.php new file mode 100644 index 000000000..642043415 --- /dev/null +++ b/app/Filament/Resources/ConfigurationResource.php @@ -0,0 +1,139 @@ +schema([ + Forms\Components\Select::make('plant_id') + ->relationship('plant', 'name') + ->required() + ->reactive(), + Forms\Components\Select::make('line_id') + ->label('Line') + ->required() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (!$plantId) { + return []; + } + return \App\Models\Line::where('plant_id', $plantId)->pluck('name', 'id')->toArray(); + }) + ->reactive(), + Forms\Components\TextInput::make('c_type') + ->label('Type') + ->required(), + Forms\Components\TextInput::make('c_group') + ->label('Group') + ->required(), + Forms\Components\TextInput::make('c_name') + ->label('Name') + ->required(), + Forms\Components\TextInput::make('c_value') + ->label('Value') + ->required(), + ]); + } + + 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('line.name') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('c_type') + ->numeric() + ->label('Type') + ->sortable(), + Tables\Columns\TextColumn::make('c_group') + ->label('Group') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('c_name') + ->label('Name') + ->numeric() + ->sortable(), + Tables\Columns\TextColumn::make('c_value') + ->label('Value') + ->numeric() + ->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\ListConfigurations::route('/'), + 'create' => Pages\CreateConfiguration::route('/create'), + 'view' => Pages\ViewConfiguration::route('/{record}'), + 'edit' => Pages\EditConfiguration::route('/{record}/edit'), + ]; + } + + public static function getEloquentQuery(): Builder + { + return parent::getEloquentQuery() + ->withoutGlobalScopes([ + SoftDeletingScope::class, + ]); + } +} diff --git a/app/Filament/Resources/ConfigurationResource/Pages/CreateConfiguration.php b/app/Filament/Resources/ConfigurationResource/Pages/CreateConfiguration.php new file mode 100644 index 000000000..1a71e2131 --- /dev/null +++ b/app/Filament/Resources/ConfigurationResource/Pages/CreateConfiguration.php @@ -0,0 +1,12 @@ +belongsTo(Plant::class); + } + + public function line(): BelongsTo + { + return $this->belongsTo(Line::class); + } +} diff --git a/database/migrations/2025_05_22_182449_create_configurations_table.php b/database/migrations/2025_05_22_182449_create_configurations_table.php new file mode 100644 index 000000000..e9a0110da --- /dev/null +++ b/database/migrations/2025_05_22_182449_create_configurations_table.php @@ -0,0 +1,46 @@ +