import new
This commit is contained in:
1 parent
df55380236
commit
228927274d
12 files changed
+272
-207
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\ProjektAllgemeinflaechen;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class ImportAllgemeinDirect
|
||||
{
|
||||
public static function run($data, $projekte_id)
|
||||
{
|
||||
$data = explode(PHP_EOL, $data['upload_data']);
|
||||
|
||||
$new = 0;
|
||||
foreach ($data as $row) {
|
||||
$row = str_replace(';', '|', $row);
|
||||
$cells = explode('|', $row);
|
||||
|
||||
$geschoss = trim($cells[1]);
|
||||
$raumart = trim($cells[2]);
|
||||
$flaeche = (float) str_replace(',', '.', trim($cells[3]));
|
||||
|
||||
if (is_numeric($flaeche) && $flaeche > 0) {
|
||||
|
||||
$allgemein = new ProjektAllgemeinflaechen;
|
||||
$allgemein->projekte_id = $projekte_id;
|
||||
$allgemein->geschoss = $geschoss;
|
||||
$allgemein->raumart = $raumart;
|
||||
$allgemein->flaeche = $flaeche;
|
||||
$allgemein->save();
|
||||
$new++;
|
||||
}
|
||||
}
|
||||
Notification::make()
|
||||
->title('Allgemeinflächen wurden erfolgreich importiert')
|
||||
->body($new.' wurden Flächen hinzugefügt')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$recipient = auth()->user();
|
||||
Notification::make()
|
||||
->title('Allgemeinflächen wurden erfolgreich importiert')
|
||||
->body($new.' wurden Flächen hinzugefügt')
|
||||
->success()
|
||||
->sendToDatabase($recipient);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user