allgemeinflaechen
This commit is contained in:
1 parent
4204c74406
commit
0b18eea9d7
15 files changed
+140
-145
No files matched your search
@@ -16,4 +16,12 @@ class EditProjekte extends EditRecord
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
// protected function getFormActions(): array
|
||||
// {
|
||||
// return [
|
||||
// $this->getSaveFormAction()->label('Sichern'),
|
||||
// $this->getCancelFormAction()->label('Zurück zu Liste'),
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
@@ -6,7 +6,6 @@ use App\Filament\Clusters\Projekte\ProjekteCluster;
|
||||
use App\Filament\Resources\Projektes\Pages\CreateProjekte;
|
||||
use App\Filament\Resources\Projektes\Pages\EditProjekte;
|
||||
use App\Filament\Resources\Projektes\Pages\ListProjektes;
|
||||
use App\Filament\Resources\Projektes\RelationManagers\ProjekteImportsRelationManager;
|
||||
use App\Filament\Resources\Projektes\Schemas\ProjekteForm;
|
||||
use App\Filament\Resources\Projektes\Tables\ProjektesTable;
|
||||
use App\Models\Projekte;
|
||||
@@ -46,7 +45,6 @@ class ProjekteResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
ProjekteImportsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projektes\RelationManagers;
|
||||
|
||||
use Filament\Actions\AssociateAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class ProjekteImportsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'projekte_imports';
|
||||
|
||||
protected static ?string $title = 'Import Daten';
|
||||
|
||||
protected static ?string $navigationLabel = 'Import';
|
||||
|
||||
protected static ?string $modelLabel = 'Import';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Import';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('filetype')
|
||||
->label('Dokument Type')
|
||||
->required()
|
||||
->options([
|
||||
'allgemein' => 'Allgemeinflächen',
|
||||
'nutzwerte' => 'Nutzwerte',
|
||||
]),
|
||||
FileUpload::make('file')
|
||||
->required()
|
||||
->disabledOn('edit')
|
||||
->label('Datei (csv/txt) auswählen')
|
||||
->directory('projekt-data-files')
|
||||
->storeFileNamesIn('original_name')
|
||||
->moveFiles()
|
||||
->acceptedFileTypes(['text/csv', 'text/plain']),
|
||||
Textarea::make('beschreibung')
|
||||
->maxLength(255),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('name')
|
||||
->columns([
|
||||
TextColumn::make('filetype')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'allgemein' => 'success',
|
||||
'nutzwerte' => 'info',
|
||||
}),
|
||||
TextColumn::make('original_name')
|
||||
->label('name')
|
||||
->wrap()
|
||||
->description(function ($record) {
|
||||
return new HtmlString($record->beschreibung);
|
||||
}),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
// CreateAction::make(),
|
||||
// AssociateAction::make(),
|
||||
CreateAction::make()
|
||||
->createAnother(false)
|
||||
->label('Hochladen')
|
||||
->color('primary')
|
||||
->icon('heroicon-o-document-arrow-up')
|
||||
->before(function (array $data) {
|
||||
|
||||
$path = Storage::disk('private')->path($data['file']);
|
||||
$contents = file_get_contents($path);
|
||||
$arr = preg_split("/\r\n|\n|\r/", $contents);
|
||||
dd($arr);
|
||||
// Runs before the form fields are saved to the database.
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton()->color('gray'),
|
||||
DeleteAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user