import table make raumealle table depending on orientierung
This commit is contained in:
1 parent
92bdc77eee
commit
7343c26955
14 files changed
+182
-108
No files matched your search
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProjektRaeumealle;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class ProjektRaeumealleImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = ProjektRaeumealle::class;
|
||||
|
||||
public function resolveRecord(): ProjektRaeumealle
|
||||
{
|
||||
$raeumealle = new ProjektRaeumealle;
|
||||
$raeumealle->projekte_id = $this->options['projekte_id'];
|
||||
|
||||
return $raeumealle;
|
||||
}
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('top_nummer')
|
||||
->label('Top Nummer')
|
||||
->validationAttribute('Top Nummer')
|
||||
->requiredMapping()
|
||||
->example('EG')
|
||||
->rules(['required', 'max:255'])
|
||||
->castStateUsing(function (string $state) {
|
||||
$state = trim($state);
|
||||
|
||||
return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
}),
|
||||
ImportColumn::make('geschoss')
|
||||
->validationAttribute('Geschoss')
|
||||
->requiredMapping()
|
||||
->example('EG')
|
||||
->rules(['required', 'max:255'])
|
||||
->castStateUsing(function (string $state) {
|
||||
$state = trim($state);
|
||||
|
||||
return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
}),
|
||||
ImportColumn::make('raumart')
|
||||
->validationAttribute('Raumart')
|
||||
->requiredMapping()
|
||||
->example('Stiegenhaus')
|
||||
->rules(['required', 'max:32'])
|
||||
->castStateUsing(function (string $state) {
|
||||
$state = trim($state);
|
||||
|
||||
return iconv(mb_detect_encoding($state, mb_detect_order(), true), 'UTF-8', $state);
|
||||
}),
|
||||
ImportColumn::make('flaeche')
|
||||
->label('Fläche')
|
||||
->validationAttribute('Fläche')
|
||||
->requiredMapping()
|
||||
->rules(['required'])
|
||||
->example('52,75')
|
||||
->castStateUsing(function (string $state): ?float {
|
||||
if (blank($state)) {
|
||||
return '0.00';
|
||||
}
|
||||
|
||||
$state = str_replace(',', '.', $state);
|
||||
$state = preg_replace('/[^0-9.]/', '', $state);
|
||||
|
||||
return round($state, precision: 2);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = ' Der Import der Räume ist abgeschlossen. Es wurden '.Number::format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' importiert.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' Bei '.Number::format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' ist der Import fehlgeschlagen.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user