import new
This commit is contained in:
1 parent
df55380236
commit
228927274d
12 files changed
+272
-207
No files matched your search
+26
-4
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use App\Filament\Imports\ImportObjekteDirect;
|
||||
use App\Models\ProjektObjekteImDetail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
@@ -10,6 +11,7 @@ use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -68,7 +70,7 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->emptyStateDescription('Schalten Sie das Projekt frei und importieren Sie die Daten der Objekte.')
|
||||
->emptyStateDescription('Bitte Projekt freischalten und Daten hochladen.')
|
||||
->striped()
|
||||
->recordTitleAttribute('top_nummer')
|
||||
->columns([
|
||||
@@ -139,20 +141,40 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
||||
])
|
||||
->deferFilters(false)
|
||||
->headerActions([
|
||||
Action::make('import-text')
|
||||
->icon('phosphor-upload')
|
||||
->modalIcon('phosphor-file-csv')
|
||||
->color('info')
|
||||
->label('Hochladen')
|
||||
->modalHeading('Objekte im Detail hochladen')
|
||||
->modalDescription(new HtmlString('<b>Objekte werden immer hinzugefügt!</b><br/>Spalten-Separator ist der Strichpunkt ";" oder die Pfeife "|"'))
|
||||
->schema([
|
||||
Textarea::make('upload_data')
|
||||
->required()
|
||||
->label('Text hier einfügen:')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->rows(5),
|
||||
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
ImportObjekteDirect::run($data, $this->ownerRecord->id);
|
||||
}),
|
||||
CreateAction::make()
|
||||
->icon('phosphor-file-plus')
|
||||
->createAnother(false),
|
||||
Action::make('nutzwerte')
|
||||
->label('Nutzwerte')
|
||||
->icon('phosphor-gear')
|
||||
->icon('phosphor-calculator')
|
||||
->action(function () {
|
||||
$res = ProjektObjekteImDetail::with('methode')
|
||||
->where('projekte_id', $this->getOwnerRecord()->id)
|
||||
->get();
|
||||
|
||||
foreach ($res as $row) {
|
||||
ProjektObjekteImDetail::where('id', $row->id)
|
||||
->update(['nutzwert' => $row->flaeche * $row->methode->faktor]);
|
||||
if ($row->methode?->faktor || null) {
|
||||
ProjektObjekteImDetail::where('id', $row->id)
|
||||
->update(['nutzwert' => $row->flaeche * $row->methode->faktor]);
|
||||
}
|
||||
}
|
||||
|
||||
})->after(function (Component $livewire) {
|
||||
|
||||
Reference in new issue
Block a user