From 6e7ebd7a9ef0009c96fed77e5be2e71ae5603815 Mon Sep 17 00:00:00 2001 From: salam Date: Wed, 4 Feb 2026 19:38:59 +0100 Subject: [PATCH] add Custom Groups --- app/Actions/LoadCountryGroups.php | 32 +++++++ .../Resources/Events/Tables/EventsTable.php | 24 ++++- app/Livewire/ClientGroupListEditor.php | 87 +++++++++++++++++++ app/Models/ClientGroupList.php | 24 +++++ app/Models/CompetitionGroup.php | 5 -- ...173319_create_client_group_lists_table.php | 31 +++++++ .../columns/mapper-left-column.blade.php | 2 +- .../columns/mapper-right-column.blade.php | 2 +- .../client-group-list-editor.blade.php | 7 ++ .../views/livewire/top-menu-items.blade.php | 10 +++ todo.md | 6 -- 11 files changed, 216 insertions(+), 14 deletions(-) create mode 100644 app/Actions/LoadCountryGroups.php create mode 100644 app/Livewire/ClientGroupListEditor.php create mode 100644 app/Models/ClientGroupList.php create mode 100644 database/migrations/2026_02_04_173319_create_client_group_lists_table.php create mode 100644 resources/views/livewire/client-group-list-editor.blade.php diff --git a/app/Actions/LoadCountryGroups.php b/app/Actions/LoadCountryGroups.php new file mode 100644 index 00000000..505a6b17 --- /dev/null +++ b/app/Actions/LoadCountryGroups.php @@ -0,0 +1,32 @@ +select('name', 'id')->get(); + $countries = []; + foreach ($res as $value) { + $countries[$value->id] = $value->name; + } + + $res = CompetitionGroup::where('sport_id', auth()->user()->sport_id)->select('country_id', 'name', 'id')->get(); + + $arr = []; + foreach ($res as $value) { + if (isset($countries[$value->country_id])) { + $arr[$value->id] = $countries[$value->country_id].' '.$value->name; + } else { + $arr[$value->id] = $value->name; + } + } + asort($arr); + + return $arr; + } +} diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 5c9f51e9..d7fb7847 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -10,6 +10,7 @@ use App\Filament\Tables\Columns\ColumnOdds; use App\Filament\Tables\Columns\EventColumn; use App\Filament\Tables\Columns\MatchIds; use App\Filament\Tables\Columns\TooltipOdds; +use App\Models\ClientGroupList; use App\Models\CompetitionGroup; use App\Models\Country; use App\Models\Event; @@ -180,7 +181,7 @@ class EventsTable ->extremePaginationLinks() ->filters([ Filter::make('events') - ->columns(6)->columnSpan(6) + ->columns(7)->columnSpan(7) ->schema([ Hidden::make('filter_alarm_green'), Hidden::make('filter_alarm_yellow'), @@ -253,6 +254,15 @@ class EventsTable return $arr; }) ->live(), + Select::make('client_group_list_id') + ->placeholder('Custom Groups') + ->prefixIcon('phosphor-user-list') + ->searchable() + ->hiddenLabel() + ->label('') + ->preload() + ->options(fn () => ClientGroupList::where('sport_id', auth()->user()->sport_id)->where('client_id', auth()->user()->client_id)->pluck('name', 'id')) + ->live(), DateRangePicker::make('starttime_period') ->columnSpan(2) @@ -290,6 +300,13 @@ class EventsTable )->when( $data['competition_group_id'], fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id) + + )->when( + $data['client_group_list_id'], + function (Builder $query, $client_group_list_id) { + $client_group_list_ids = ClientGroupList::where('id', $client_group_list_id)->value('client_groups'); + $query->whereIn('competition_group_id', $client_group_list_ids); + } )->when( $data['starttime_period'], function (Builder $query, $starttime_period) { @@ -448,6 +465,11 @@ class EventsTable } } + if ($data['client_group_list_id'] ?? null) { + $client_group_list_name = ClientGroupList::where('id', $data['client_group_list_id'])->value('name'); + $indicators[] = Indicator::make('Custom Group: '.$client_group_list_name)->removeField('client_group_list_id')->color('info'); + } + if ($data['filter_stars'] ?? null) { $indicators[] = Indicator::make('Filter Favorits')->removeField('filter_stars')->color('info'); } diff --git a/app/Livewire/ClientGroupListEditor.php b/app/Livewire/ClientGroupListEditor.php new file mode 100644 index 00000000..e4af259f --- /dev/null +++ b/app/Livewire/ClientGroupListEditor.php @@ -0,0 +1,87 @@ +query(ClientGroupList::query()) + ->columns([ + TextColumn::make('name'), + TextColumn::make('client_groups') + ->label('Leagues') + ->badge() + ->wrap() + ->color('info') + ->formatStateUsing(fn (string $state): string => CompetitionGroup::where('id', $state)->pluck('name')->first()), + ]) + ->filters([ + // ... + ]) + ->recordActions([ + EditAction::make('edit') + ->iconButton() + ->mutateDataUsing(function (array $data): array { + $data['client_id'] = auth()->user()->client_id; + $data['sport_id'] = auth()->user()->sport_id; + + return $data; + }) + ->schema([ + TextInput::make(name: 'name') + ->required() + ->maxLength(255), + Select::make('client_groups') + ->searchable() + ->multiple() + ->preload() + ->options(fn () => LoadCountryGroups::load()), + ])->action(function ($livewire) { + $livewire->dispatch('refreshBettypeMenu'); + }), + DeleteAction::make('delete')->iconButton(), + ]) + ->headerActions([ + CreateAction::make() + ->label('New Group') + ->schema([ + TextInput::make(name: 'name') + ->required() + ->maxLength(255), + Select::make('client_groups') + ->searchable() + ->options(fn () => LoadCountryGroups::load()), + ]), + ]); + } + + public function render(): View + { + return view('livewire.client-group-list-editor'); + } +} diff --git a/app/Models/ClientGroupList.php b/app/Models/ClientGroupList.php new file mode 100644 index 00000000..56a17da7 --- /dev/null +++ b/app/Models/ClientGroupList.php @@ -0,0 +1,24 @@ + 'json', + ]; + + protected $fillable = [ + 'name', + 'sport_id', + 'client_id', + 'client_groups', + ]; + + public function client_group() + { + return $this->belongsTo(CompetitionGroup::class)->with('country'); + } +} diff --git a/app/Models/CompetitionGroup.php b/app/Models/CompetitionGroup.php index ade56cde..d3841d3f 100644 --- a/app/Models/CompetitionGroup.php +++ b/app/Models/CompetitionGroup.php @@ -23,9 +23,4 @@ class CompetitionGroup extends Model { return $this->belongsTo(Sport::class); } - - public function country() - { - return $this->belongsTo(Country::class)->where('disabled', 0)->where('is_country', 1); - } } diff --git a/database/migrations/2026_02_04_173319_create_client_group_lists_table.php b/database/migrations/2026_02_04_173319_create_client_group_lists_table.php new file mode 100644 index 00000000..bc91e863 --- /dev/null +++ b/database/migrations/2026_02_04_173319_create_client_group_lists_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('name'); + $table->integer('sport_id')->index()->references('id')->on('sports'); + $table->integer('client_id'); + $table->text('client_groups')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('client_group_lists'); + } +}; diff --git a/resources/views/filament/tables/columns/mapper-left-column.blade.php b/resources/views/filament/tables/columns/mapper-left-column.blade.php index 0b4eac21..fa5a8638 100644 --- a/resources/views/filament/tables/columns/mapper-left-column.blade.php +++ b/resources/views/filament/tables/columns/mapper-left-column.blade.php @@ -16,7 +16,7 @@ draggable="true" mapper="left"> -
+
{{ $record->home->name }}
-
{{ $record->away->name }}
diff --git a/resources/views/filament/tables/columns/mapper-right-column.blade.php b/resources/views/filament/tables/columns/mapper-right-column.blade.php index e02900f6..cb60e045 100644 --- a/resources/views/filament/tables/columns/mapper-right-column.blade.php +++ b/resources/views/filament/tables/columns/mapper-right-column.blade.php @@ -24,7 +24,7 @@ @include('filament.tables.columns.parts.search-right', ['find' => $record->home, 'color' => 'away'])
-
+
{{ $record->home }}
-
{{ $record->away }}
diff --git a/resources/views/livewire/client-group-list-editor.blade.php b/resources/views/livewire/client-group-list-editor.blade.php new file mode 100644 index 00000000..3a2d7d58 --- /dev/null +++ b/resources/views/livewire/client-group-list-editor.blade.php @@ -0,0 +1,7 @@ +
+ + {{ auth()->user()->sport->name }} - Custom Groups + + + {{ $this->table }} +
diff --git a/resources/views/livewire/top-menu-items.blade.php b/resources/views/livewire/top-menu-items.blade.php index 5213e4a9..aefc849e 100644 --- a/resources/views/livewire/top-menu-items.blade.php +++ b/resources/views/livewire/top-menu-items.blade.php @@ -210,5 +210,15 @@ @livewire('comparing-bookmaker-menu') + + {{-- Custom Groups --}} + + + + + + @livewire('client-group-list-editor') + @endif
diff --git a/todo.md b/todo.md index 1f2592b5..ab2e7823 100644 --- a/todo.md +++ b/todo.md @@ -14,12 +14,6 @@ tq shows 0 in odds tq filter if bkm in compere take from slot -MAPPER -1) add date select -2) submit with return -3) sort by date -4) click on lega for selection -4) window bigger [PDF] https://txodds.com/docs/TXODDS_TXAPI_Market_Odds_Feed_User_Guide.pdf