From ed9e1db12e61cd0fcdf3e3ef587a4ad9590a074c Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 11 Oct 2026 07:26:01 +0200 Subject: [PATCH] wip fixes --- .../Tables/SofaScoreRosasTable.php | 56 ++------ .../Tables/SofaScoreTournamentsTable.php | 125 +----------------- .../Tables/StatistikoConfigsTable.php | 1 + .../Tables/StatistikoDetailsTable.php | 23 ++-- .../Tables/StatistikoPlayersTable.php | 25 ++-- app/Models/SofaScoreRosa.php | 4 +- app/Models/StatistikoEvent.php | 3 +- database/seeders/StatistikoConfigSeeder.php | 4 +- 8 files changed, 46 insertions(+), 195 deletions(-) diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php index 126b3fc8..ec0de117 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php @@ -2,12 +2,9 @@ namespace App\Filament\Clusters\StaticData\Resources\SofaScoreRosas\Tables; -use App\Models\SofaScoreRosaTournament; -use App\Models\SofaScoreTournament; -use App\Models\Sport; -use Filament\Forms\Components\Select; -use Filament\Schemas\Components\Utilities\Get; +use Filament\Forms\Components\Toggle; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\Filter; use Filament\Tables\Table; @@ -20,59 +17,24 @@ class SofaScoreRosasTable return $table ->defaultPaginationPageOption(50) ->columns([ - TextColumn::make('ss_team_id')->label('SSId')->badge()->width('1rem') - ->sortable(), - TextColumn::make('sofascore_category.name')->label('Country') - ->sortable(), - TextColumn::make('tournament_rosa.tournament.name')->label('Tournament') + TextColumn::make('ss_team_id')->label('SofaId')->badge()->width('1rem') ->sortable(), + TextColumn::make('cc'), TextColumn::make('ss_team_name')->label('Name') ->searchable() ->sortable(), - TextColumn::make('updated_at')->dateTime('Y-m-d H:i:s') - ->sortable() - + ToggleColumn::make('is_active'), ]) ->filters([ Filter::make('filters') - ->columns(3)->columnSpan(3) + ->columns(7)->columnSpan(7) ->schema([ - Select::make('sport_id') - ->default(1) - ->selectablePlaceholder(false) - ->label('Sport') - ->options(Sport::where('is_active', 1)->pluck('name', 'id')) - ->afterStateUpdated(function (callable $set) { - $set('ss_tournament_id', null); - }) - ->live(), - Select::make('ss_tournament_id') - // ->default(23) - ->label('Tournament') - ->selectablePlaceholder(true) - ->options(function (Get $get) { - $res = SofaScoreTournament::with('sofascore_category')->where('enabled', 1)->where('sport_id', $get('sport_id'))->get(); - $return = []; - foreach ($res as $value) { - $return[$value->tournament_id] = $value->sofascore_category->name . ' - ' . $value->name; - } - asort($return); - - return $return; - }) - ->live(), + Toggle::make('is_active')->label('In Statistiko')->default(1), ]) ->query(function (Builder $query, array $data): Builder { return $query->when( - $data['sport_id'], - fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id) - )->when( - $data['ss_tournament_id'], - function (Builder $query, $ss_tournament_id) { - $ss_team_ids = SofaScoreRosaTournament::where('ss_tournament_id', $ss_tournament_id)->pluck('ss_team_id')->toArray(); - - $query->whereIn('ss_team_id', $ss_team_ids); - } + $data['is_active'], + fn (Builder $query, $is_active) => $query->where('is_active', $is_active) ); }), ], layout: FiltersLayout::AboveContent) diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php index 15d9f9df..136c0a63 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php @@ -2,12 +2,7 @@ namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables; -use App\Models\SofaScoreCategory; -use App\Models\SofaScoreTournament; -use App\Models\Sport; -use Filament\Forms\Components\Select; use Filament\Forms\Components\Toggle; -use Filament\Schemas\Components\Utilities\Get; use Filament\Support\Enums\IconSize; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; @@ -16,7 +11,6 @@ use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\Filter; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; -// use Illuminate\Database\Eloquent\Collection; class SofaScoreTournamentsTable { @@ -28,10 +22,10 @@ class SofaScoreTournamentsTable ->label('') ->grow(false) ->width(30) - ->color(fn($record) => $record->sport->color) - ->icon(fn($record) => $record->sport->icon) + ->color(fn ($record) => $record->sport->color) + ->icon(fn ($record) => $record->sport->icon) ->size(IconSize::Medium) - ->tooltip(fn($record) => $record->id) + ->tooltip(fn ($record) => $record->id) ->visibleFrom('lg'), TextColumn::make('sport.name') ->sortable(), @@ -41,7 +35,7 @@ class SofaScoreTournamentsTable ->searchable(), TextColumn::make('sofascore_category.name') ->label('Country') - ->icon(fn($record) => $record->sofascore_category->flag) + ->icon(fn ($record) => $record->sofascore_category->flag) ->sortable(), TextColumn::make('name')->searchable()->sortable(), ToggleColumn::make('enabled') @@ -53,124 +47,15 @@ class SofaScoreTournamentsTable Filter::make('filters') ->columns(7)->columnSpan(7) ->schema([ - Select::make('sport_id') - ->default(1) - ->selectablePlaceholder(false) - ->label('Sport') - ->options(Sport::where('is_active', 1)->pluck('name', 'id')) - ->afterStateUpdated(function (callable $set) { - $set('sofa_score_category_id', null); - }) - ->live(), - Select::make('sofa_score_category_id') - ->searchable() - ->multiple() - ->columnSpan(2) - ->label('Categorie') - ->options(function (Get $get) { - $res = SofaScoreTournament::where('sport_id', $get('sport_id')) - ->groupBy('sofa_score_category_id') - ->pluck('sofa_score_category_id') - ->toArray(); - - return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); - }) - ->live(), Toggle::make('enabled')->label('In Statistiko')->default(1), ]) ->query(function (Builder $query, array $data): Builder { return $query->when( - $data['sport_id'], - fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id) - )->when( $data['enabled'], - fn(Builder $query, $enabled) => $query->where('enabled', $enabled) - )->when( - $data['sofa_score_category_id'], - function (Builder $query, $sofa_score_category_id) { - if (is_array($sofa_score_category_id)) { - $query->whereIn('sofa_score_category_id', $sofa_score_category_id); - } else { - $query->where('sofa_score_category_id', $sofa_score_category_id); - } - } - // )->when( - // $data['filter-grapping'], - // function (Builder $query, $filtergrapping) { - // switch ($filtergrapping) { - // case 'active': - // $query->where('enabled', 1); - // break; - // case 'disabled': - // $query->where('enabled', 0); - // break; - // } - // } - // )->when( - // $data['filter-disabled'], - // function (Builder $query, $filterdisabled) { - // switch ($filterdisabled) { - // case 'enabled': - // $query->where('enabled', 1); - // break; - // case 'hidden': - // $query->where('disabled', 1); - // break; - // } - // } + fn (Builder $query, $enabled) => $query->where('enabled', $enabled) ); }), ], layout: FiltersLayout::AboveContent) ->deferFilters(false); - // ->toolbarActions([ - // BulkActionGroup::make([ - // BulkAction::make('Enable selected') - // ->icon('phosphor-toggle-right-fill') - // ->color('primary') - // ->action(function (Collection $records): void { - // foreach ($records as $record) { - // SofaScoreTournament::where('id', '=', $record->id) - // ->update( - // ['enabled' => 1] - // ); - // } - // }), - // BulkAction::make('Disable selected') - // ->icon('phosphor-toggle-left-fill') - // ->color('gray') - // ->action(function (Collection $records): void { - // foreach ($records as $record) { - // SofaScoreTournament::where('id', '=', $record->id) - // ->update( - // ['enabled' => 0] - // ); - // } - // }), - // ])->label('Grapping'), - // BulkActionGroup::make([ - // BulkAction::make('Hide selected') - // ->icon('phosphor-toggle-right-fill') - // ->color('primary') - // ->action(function (Collection $records): void { - // foreach ($records as $record) { - // SofaScoreTournament::where('id', '=', $record->id) - // ->update( - // ['disabled' => 1] - // ); - // } - // }), - // BulkAction::make('Show selected') - // ->icon('phosphor-toggle-left-fill') - // ->color('gray') - // ->action(function (Collection $records): void { - // foreach ($records as $record) { - // SofaScoreTournament::where('id', '=', $record->id) - // ->update( - // ['disabled' => 0] - // ); - // } - // }), - // ])->label('Hidden'), - // ]); } } diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoConfigs/Tables/StatistikoConfigsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoConfigs/Tables/StatistikoConfigsTable.php index a8b1c6f5..df71bdfc 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoConfigs/Tables/StatistikoConfigsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoConfigs/Tables/StatistikoConfigsTable.php @@ -28,6 +28,7 @@ class StatistikoConfigsTable ->color(fn (string $state): string => match ($state) { 'home' => 'info', 'away' => 'warning', + default => '' }), TextColumn::make('varname') ->formatStateUsing(fn (string $state): string => strtoupper($state)), diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php index 7575be33..ebf5f39a 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoDetails/Tables/StatistikoDetailsTable.php @@ -16,6 +16,15 @@ use Illuminate\Database\Eloquent\Builder; class StatistikoDetailsTable { + /** + * Eingebettete Dokumente (Embeds): Falls Sie mal in einem verschachtelten MongoDB-Objekt suchen müssen (z. B. address.city), + * können Sie das in der $subQuery einfach in der Dot-Notation angeben: + * $subQuery->orWhere('address.city', 'regexp', '/' . $search . '/i'). + * + * Indexierung: Da Regex-Suchen rechenintensiv sein können, + * lohnt es sich, bei wachsenden Datenmengen einen Index auf die durchsuchten Felder + * (wie name oder email) in Ihrer MongoDB zu legen. + */ public static function configure(Table $table): Table { return $table @@ -32,9 +41,9 @@ class StatistikoDetailsTable ->copyable() ->searchable(query: function (Builder $query, string $search): Builder { return $query->where(function (Builder $subQuery) use ($search) { - // MongoDB-sichere Suche über 'name' ODER 'email' mittels Regex - $subQuery->where('name', 'regexp', '/'.$search.'/i') - ->orWhere('email', 'regexp', '/'.$search.'/i'); + // MongoDB-sichere Regex-Suche über Name ODER E-Mail + $subQuery->where('player_name', 'regexp', '/'.$search.'/i') + ->orWhere('player_name', 'regexp', '/'.$search.'/i'); }); }), TextColumn::make('ss_player_id') @@ -53,13 +62,6 @@ class StatistikoDetailsTable TextColumn::make('last_update')->date()->prefix('Last Update: '), ]), ]) - ->searchQuery(function (Builder $query, string $search): Builder { - return $query->where(function (Builder $subQuery) use ($search) { - // Nutzen Sie 'regexp' als Operator und packen Sie Flags in den String /.../i - $subQuery->where('name', 'regexp', '/'.$search.'/i') - ->orWhere('email', 'regexp', '/'.$search.'/i'); - }); - }) ->emptyStateHeading('No double player in details') ->contentGrid([ 'md' => 2, @@ -88,7 +90,6 @@ class StatistikoDetailsTable return 'Find Double'; }), - ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->recordActions([ diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php index efe31765..0e070d27 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoPlayers/Tables/StatistikoPlayersTable.php @@ -7,6 +7,8 @@ use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Enums\FiltersLayout; +use Filament\Tables\Filters\Filter; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; @@ -19,27 +21,29 @@ class StatistikoPlayersTable TextColumn::make('match_id')->color('info')->icon('phosphor-copy')->copyable() ->sortable() ->searchable( - query: fn($query, $search) => $query->orWhere('match_id', (int) $search) + query: fn ($query, $search) => $query->orWhere('match_id', (int) $search) ), TextColumn::make('ss_player_id') ->sortable() ->label('Player Id') ->color('success')->icon('phosphor-copy')->copyable() ->searchable( - query: fn($query, $search) => $query->orWhere('ss_player_id', (int) $search) - ), - TextColumn::make('details.player_name')->label('Player')->searchable() - ->tooltip(fn($record) => $record->details->full_name) - ->sortable( - query: fn(Builder $query) => $query->orderBy('details.player_name') + query: fn ($query, $search) => $query->orWhere('ss_player_id', (int) $search) ), + TextColumn::make('details.player_name')->label('Player') + ->searchable(query: function (Builder $query, string $search): Builder { + return $query->where(function (Builder $subQuery) use ($search) { + $subQuery->where('details.player_name', 'regexp', '/'.$search.'/i') + ->orWhere('details.player_name', 'regexp', '/'.$search.'/i'); + }); + }), TextColumn::make('event.home.ss_team_name')->color('primary')->searchable() ->sortable( - query: fn(Builder $query) => $query->orderBy('event.home.ss_team_name') + query: fn (Builder $query) => $query->orderBy('event.home.ss_team_name') ), TextColumn::make('event.away.ss_team_name')->searchable()->color('success') ->sortable( - query: fn(Builder $query) => $query->orderBy('ss_team_name') + query: fn (Builder $query) => $query->orderBy('ss_team_name') ), ]) // ->filters([ @@ -55,13 +59,11 @@ class StatistikoPlayersTable // foreach ($events as $value) { // $match_id = $value['match_id']; // $player_id = $value['ss_player_id']; - // if (isset($arr[$match_id]) && in_array($player_id, $arr[$match_id])) { // return $query->where('match_id', $match_id)->where('ss_player_id', $player_id); // } // $arr[$match_id][] = $player_id; // } - // return $query->where('match_id', 0); // } // ); @@ -71,7 +73,6 @@ class StatistikoPlayersTable // } // return 'Find Double'; // }), - // ], layout: FiltersLayout::AboveContent) ->emptyStateHeading('No player double in an event') ->deferFilters(false) diff --git a/app/Models/SofaScoreRosa.php b/app/Models/SofaScoreRosa.php index 9e4c2ce4..70b76cb9 100644 --- a/app/Models/SofaScoreRosa.php +++ b/app/Models/SofaScoreRosa.php @@ -11,6 +11,8 @@ class SofaScoreRosa extends Model protected $connection = 'mariadb'; + protected $table = 'sofa_score_rosas'; + protected $fillable = [ 'sport_id', 'cc', @@ -31,7 +33,7 @@ class SofaScoreRosa extends Model public function sofascore_category() { - return $this->belongsTo(SofaScoreCategory::class, 'country_id', 'country_id')->where('in_soccer', 1); + return $this->belongsTo(SofaScoreCategory::class, 'country_id', 'country_id'); } public function tournament_rosa() diff --git a/app/Models/StatistikoEvent.php b/app/Models/StatistikoEvent.php index c738ad07..a793964e 100644 --- a/app/Models/StatistikoEvent.php +++ b/app/Models/StatistikoEvent.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace App\Models; -use MongoDB\Laravel\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use MongoDB\Laravel\Eloquent\Model; class StatistikoEvent extends Model { @@ -48,7 +48,6 @@ class StatistikoEvent extends Model 'starttime' => 'datetime', ]; - public function sport(): BelongsTo { return $this->belongsTo(Sport::class, 'sport_id', 'id'); diff --git a/database/seeders/StatistikoConfigSeeder.php b/database/seeders/StatistikoConfigSeeder.php index b78c0c90..d39de9da 100644 --- a/database/seeders/StatistikoConfigSeeder.php +++ b/database/seeders/StatistikoConfigSeeder.php @@ -67,8 +67,8 @@ class StatistikoConfigSeeder extends Seeder (54, 'A', 'tsh', 'away', 'tsh_away_made_home', 1.00, NULL, NULL), (55, 'A', 'tsh', 'away', 'tsh_away_got_total', 1.00, NULL, NULL), (56, 'A', 'tsh', 'away', 'tsh_away_got_home', 1.00, NULL, NULL), - (57, 'B', 'all', 'home', 'asp_home', 2.00, NULL, NULL), - (58, 'B', 'all', 'away', 'asp_away', 2.00, NULL, NULL);"; + (57, 'B', 'all', 'Bet Modificator', 'cfHA', 1.00, NULL, NULL), + (58, 'B', 'all', 'Min Max', 'Y', 0.25, NULL, NULL);"; DB::unprepared($sql); }