diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Pages/CreateStatistikaImport.php b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Pages/CreateStatistikaImport.php new file mode 100644 index 00000000..1659c9f4 --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Pages/CreateStatistikaImport.php @@ -0,0 +1,11 @@ +label('Upload file') + ->icon('phosphor-upload'), + ]; + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Schemas/StatistikaImportForm.php b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Schemas/StatistikaImportForm.php new file mode 100644 index 00000000..f7bd9a9b --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Schemas/StatistikaImportForm.php @@ -0,0 +1,35 @@ +components([ + Select::make('sport_id') + ->required() + ->label('Sport') + ->options(Sport::where('is_active', 1)->pluck('name', 'id')), + Select::make('data_type') + ->required() + ->options([ + 'player' => 'Player', + 'events' => 'Events', + 'events_player' => 'Events & Player', + ]), + + FileUpload::make('file_name') + ->directory('statistika') + ->visibility('public') + ->required() + ->storeFileNamesIn('file_name_original'), + ])->columns(1); + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikaImports/StatistikaImportResource.php b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/StatistikaImportResource.php new file mode 100644 index 00000000..b9d05a8a --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/StatistikaImportResource.php @@ -0,0 +1,51 @@ +count(); + } + + public static function getPages(): array + { + return [ + 'index' => ListStatistikaImports::route('/'), + ]; + } +} diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Tables/StatistikaImportsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Tables/StatistikaImportsTable.php new file mode 100644 index 00000000..17ef7f49 --- /dev/null +++ b/app/Filament/Clusters/StaticData/Resources/StatistikaImports/Tables/StatistikaImportsTable.php @@ -0,0 +1,58 @@ +columns([ + IconColumn::make('sport.icon') + ->label('Sport') + ->icon(fn ($record) => $record->sport->icon) + ->tooltip(fn ($record) => $record->id) + ->visibleFrom('lg'), + SelectColumn::make('data_type') + ->native(false) + ->width('2rem') + ->allowOptionsHtml() + ->options([ + 'player' => 'Player', + 'events' => 'Events', + 'events_player' => 'Events & Player', + ]), + // TextColumn::make('data_type'), + TextColumn::make('file_name_original')->searchable()->color('primary')->label('Name'), + ToggleColumn::make('run_import') + ->tooltip('Import will run in the background, on compleation a message will be send.') + ->onColor(fn ($state) => $state ? 'success' : 'gray') + ->beforeStateUpdated(function ($record, $state) { + if ($state) { + $record->is_running = 1; + } + }), + IconColumn::make('is_running')->boolean()->falseColor('gray'), + IconColumn::make('has_run')->boolean()->falseColor('gray'), + TextColumn::make('created_at')->dateTime(), + + ]) + ->recordActions([ + DeleteAction::make()->iconButton(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Models/StatistikaImport.php b/app/Models/StatistikaImport.php new file mode 100644 index 00000000..bcdf9bb4 --- /dev/null +++ b/app/Models/StatistikaImport.php @@ -0,0 +1,23 @@ +belongsTo(Sport::class)->where('is_active', 1); + } +} diff --git a/database/migrations/2026_04_17_094202_create_statistika_imports_table.php b/database/migrations/2026_04_17_094202_create_statistika_imports_table.php new file mode 100644 index 00000000..4727031e --- /dev/null +++ b/database/migrations/2026_04_17_094202_create_statistika_imports_table.php @@ -0,0 +1,34 @@ +id(); + $table->integer('sport_id'); + $table->string('data_type'); + $table->string('file_name'); + $table->string('file_name_original'); + $table->boolean('run_import')->default(0); + $table->boolean('is_running')->default(0); + $table->boolean('has_run')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('statistika_imports'); + } +};