- Added ListinoRelationManager for managing price lists associated with models. - Introduced ImportaListiniAction for importing price lists from Excel files. - Created ListinoPrezzo model to represent price entries in the database. - Developed ListinoExcelParser for parsing Excel files containing price lists. - Implemented ListinoImporter to handle the import logic and associations. - Added migration for creating listino_prezzi table and converting measures to mm. - Updated frontend logic to handle new price list features and validations. - Enhanced tests for price list import and conversion functionalities.
97 lines
3.5 KiB
PHP
97 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\SistemaResource\Actions\ImportaListiniAction;
|
|
use App\Filament\Resources\SistemaResource\Pages;
|
|
use App\Models\Sistema;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class SistemaResource extends Resource
|
|
{
|
|
protected static ?string $model = Sistema::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $slug = 'sistemi';
|
|
|
|
protected static ?string $navigationGroup = 'Prodotti';
|
|
|
|
protected static ?string $navigationLabel = 'Sistemi';
|
|
|
|
protected static ?string $modelLabel = 'sistema';
|
|
|
|
protected static ?string $pluralModelLabel = 'sistemi';
|
|
|
|
protected static ?int $navigationSort = 10;
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form->schema([
|
|
Forms\Components\Section::make()
|
|
->columns(2)
|
|
->schema([
|
|
Forms\Components\TextInput::make('codice')
|
|
->label('Codice')
|
|
->helperText('Usato dal configuratore nel parametro ?sistema= (es. pvc).')
|
|
->required()
|
|
->maxLength(50)
|
|
->alphaDash()
|
|
->unique(ignoreRecord: true),
|
|
Forms\Components\TextInput::make('nome')
|
|
->label('Nome')
|
|
->required()
|
|
->maxLength(255),
|
|
Forms\Components\TextInput::make('ordine')
|
|
->label('Ordine')
|
|
->numeric()
|
|
->minValue(0)
|
|
->default(0),
|
|
Forms\Components\Toggle::make('attivo')
|
|
->label('Attivo nel configuratore')
|
|
->default(true)
|
|
->inline(false),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('ordine')
|
|
->reorderable('ordine')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('codice')->label('Codice')->searchable(),
|
|
Tables\Columns\TextColumn::make('nome')->label('Nome')->searchable(),
|
|
Tables\Columns\TextColumn::make('modelli_count')->label('Modelli')->counts('modelli'),
|
|
Tables\Columns\IconColumn::make('attivo')->label('Attivo')->boolean(),
|
|
])
|
|
->actions([
|
|
Tables\Actions\Action::make('modelli')
|
|
->label('Modelli')
|
|
->icon('heroicon-o-squares-2x2')
|
|
->color('gray')
|
|
->url(fn (Sistema $record) => ModelloResource::getUrl('index', [
|
|
'tableFilters' => ['sistema' => ['value' => $record->getKey()]],
|
|
])),
|
|
ImportaListiniAction::make(),
|
|
Tables\Actions\EditAction::make(),
|
|
Tables\Actions\DeleteAction::make()
|
|
->modalDescription('Verrà eliminato definitivamente il sistema insieme a tutti i suoi modelli.'),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListSistemi::route('/'),
|
|
'create' => Pages\CreateSistema::route('/create'),
|
|
'edit' => Pages\EditSistema::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|