diff --git a/app/Console/Commands/Grapper/Betsapi/Bwin.php b/app/Console/Commands/Grapper/Betsapi/Bwin.php index 035c0e88..6c981ee6 100644 --- a/app/Console/Commands/Grapper/Betsapi/Bwin.php +++ b/app/Console/Commands/Grapper/Betsapi/Bwin.php @@ -47,14 +47,17 @@ class Bwin foreach ($data['results'] as $event) { $betsapi_id = $event['our_event_id'] ?? 0; + $betradar_id = $event['BetRadarId'] ?? 0; + $bwin_id = $event['Id'] ?? 0; - if ($debug) { - Notice::note(["Betsapi ID : $betsapi_id", "Betradar ID : $betradar_id", "Bwin ID : $bwin_id"]); - } + if ($betradar_id && $betsapi_id) { + + if ($debug) { + Notice::note(["Betsapi ID : $betsapi_id", "Betradar ID : $betradar_id", "Bwin ID : $bwin_id"]); + } - if ($betradar_id) { Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]); Mapper::where('event_id', $betsapi_id)->delete(); diff --git a/app/Console/Commands/Grapper/Betsapi/Fixtures.php b/app/Console/Commands/Grapper/Betsapi/Fixtures.php index dce15b98..18712311 100644 --- a/app/Console/Commands/Grapper/Betsapi/Fixtures.php +++ b/app/Console/Commands/Grapper/Betsapi/Fixtures.php @@ -4,6 +4,7 @@ namespace App\Console\Commands\Grapper\Betsapi; use App\Console\Commands\Curl; use App\Console\Commands\Nuh; +use App\Models\Event; use App\Models\Mapper; use App\Models\Sport; use App\Utilities\Notice; @@ -33,7 +34,7 @@ class Fixtures $total = 1; foreach ($sportmap as $sport_id => $betsapi_sport_id) { - $sport_url = str_replace('###sport_id###', $sport_id, $base_url); + $sport_url = str_replace('###sport_id###', $betsapi_sport_id, $base_url); $page = 1; while ($page <= $total) { @@ -71,8 +72,13 @@ class Fixtures 'group_id' => (int) $row['league']['id'] ?? 0, 'group_cc' => strtoupper($row['league']['cc']) ?? '', ]; - - Mapper::updateOrCreate(['event_id' => (int) $row['id']], $event); + $event_id = (int) $row['id']; + $match_id = Event::where('betsapi_id', $event_id)->value('id'); + if ($match_id) { + Mapper::where('event_id', $event_id)->delete(); + } else { + Mapper::updateOrCreate(['event_id' => $event_id], $event); + } } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 7c6b5268..80901e12 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -28,6 +28,15 @@ class Odds Notice::note('txodd odd sport: '.Nuh::$options['sport_id'], 'b'); } + /** + * Delete + */ + $info = Event::where('starttime', '<', Carbon::now()->toDateTimeString())->delete(); + + if ($debug) { + Notice::note("Deleted: $info"); + } + /************************************************* * SINGLE SOCCER * https://xml2.txodds.com/feed/odds/xml.php?ident=betaid1&passwd=Dy59vpRC&peid=3118930 diff --git a/app/Livewire/MapperLeft.php b/app/Livewire/MapperLeft.php index e0b1c0c5..53086f8f 100644 --- a/app/Livewire/MapperLeft.php +++ b/app/Livewire/MapperLeft.php @@ -26,19 +26,24 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable use InteractsWithSchemas; use InteractsWithTable; + protected $listeners = [ + 'reload_data' => '$refresh', + ]; + public function table(Table $table): Table { return $table ->query(Event::query()->where('betradar_id', 0)) ->columns([ MapperLeftColumn::make('left')->label(''), - ])->searchable(['home.name', 'away.name']) + ]) + ->searchable(['competition_group.name', 'home.name', 'away.name']) ->defaultPaginationPageOption(5) ->filters([ SelectFilter::make('country_id') ->relationship('country', 'name') ->options( - fn (Builder $query) => $query->whereNotNull('events.country_id')->where('events.betradar_id', 0)->where('events.starttime', '>', Carbon::now()) + fn (Builder $query) => $query->where('countries.tx_id', 'events.country_id')->where('events.betradar_id', 0)->where('events.starttime', '>', Carbon::now()) ) ->searchable() ->preload() @@ -63,11 +68,19 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable ->placeholder('League') ->label('Leagues'), ], layout: FiltersLayout::AboveContent) - ->hiddenFilterIndicators() + // ->hiddenFilterIndicators() ->filtersFormColumns(3) ->deferFilters(false) ->toolbarActions([ - // ... + Action::make('reload_data_left') + ->hiddenLabel() + ->color('gray') + ->icon('phosphor-x') + ->action(function (Component $livewire) { + $livewire->resetTableFiltersForm(); // Clears all filters + $livewire->tableSearch = ''; // Clears the main search bar + $this->dispatch('reload_data'); + }), ]); } diff --git a/app/Livewire/MapperRight.php b/app/Livewire/MapperRight.php index 86a8a248..8b9a637e 100644 --- a/app/Livewire/MapperRight.php +++ b/app/Livewire/MapperRight.php @@ -24,6 +24,10 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable use InteractsWithSchemas; use InteractsWithTable; + protected $listeners = [ + 'reload_data' => '$refresh', + ]; + public function table(Table $table): Table { return $table @@ -49,9 +53,20 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable ->placeholder('League') ->label('Leagues'), ], layout: FiltersLayout::AboveContent) - ->hiddenFilterIndicators() + // ->hiddenFilterIndicators() ->filtersFormColumns(3) - ->deferFilters(false); + ->deferFilters(false) + ->toolbarActions([ + Action::make('reload_data') + ->hiddenLabel() + ->color('gray') + ->icon('phosphor-x') + ->action(function (Component $livewire) { + $livewire->resetTableFiltersForm(); // Clears all filters + $livewire->tableSearch = ''; // Clears the main search bar + $this->dispatch('reload_data'); + }), + ]); } public function rightAction(): Action diff --git a/app/Models/Event.php b/app/Models/Event.php index 2e6caed3..0c88279c 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -41,21 +41,21 @@ class Event extends Model public function group() { - return $this->hasOne(Group::class, 'id', 'group_id'); + return $this->belongsTo(Group::class); } public function competition_group() { - return $this->hasOne(CompetitionGroup::class, 'id', 'competition_group_id'); + return $this->belongsTo(CompetitionGroup::class); } public function home() { - return $this->hasOne(Element::class, 'id', 'home_id'); + return $this->belongsTo(Element::class); } public function away() { - return $this->hasOne(Element::class, 'id', 'away_id'); + return $this->belongsTo(Element::class); } } diff --git a/app/Models/MultilineClient.php b/app/Models/MultilineClient.php index 490fd0a3..aa527555 100644 --- a/app/Models/MultilineClient.php +++ b/app/Models/MultilineClient.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Models\Scopes\ClientScope; +use App\Models\Scopes\SportScope; use Illuminate\Database\Eloquent\Model; class MultilineClient extends Model @@ -34,5 +35,8 @@ class MultilineClient extends Model protected static function booted(): void { static::addGlobalScope(new ClientScope); + + static::addGlobalScope(new SportScope); + } } diff --git a/resources/css/filament/admin/theme.css b/resources/css/filament/admin/theme.css index 8dad71f4..96302a5b 100644 --- a/resources/css/filament/admin/theme.css +++ b/resources/css/filament/admin/theme.css @@ -30,4 +30,23 @@ button[wire\:click="resetTableFiltersForm"] { .fi-ta-header-cell-oddsdc, .fi-ta-header-cell-id { @apply !text-center +} + + +#mapper { + @layer components { + .fi-ta-ctn { + & .fi-ta-header-toolbar { + @apply !flex-row-reverse; + flex-wrap: inherit; + } + } + + .fi-pagination { + & .fi-pagination-overview { + display: block; + font-size: 11px; + } + } + } } \ No newline at end of file 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 c7c41445..ee431805 100644 --- a/resources/views/filament/tables/columns/mapper-left-column.blade.php +++ b/resources/views/filament/tables/columns/mapper-left-column.blade.php @@ -1,11 +1,11 @@ -