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(), ]); } }