This commit is contained in:
salam committed 2026-01-19 08:48:39 +01:00
1 parent 4184acdb8a
commit 8f1aeafe46
10 files changed
+136 -55

No files matched your search

+11 -12
View File
@@ -17,12 +17,10 @@ class Bwin
$sportmap = Sport::map('bwin');
$sportmap = [4];
$total = 1;
foreach ($sportmap as $sport_id => $bwin_sport_id) {
foreach ($sportmap as $bwin_sport_id) {
$page = 1;
$total = 10;
/**
* BWIN ODDS & BETRADAR ID (per page)
@@ -32,24 +30,25 @@ class Bwin
while ($page <= $total) {
if ($debug) {
Notice::note("Page: $page \Sport: $bwin_sport_id", 'b');
}
$url = str_replace('###page###', $page, $base_url);
$data = Curl::load($url);
if (! isset($data['pager'])) {
return;
}
$total = round($data['pager']['total'] / $data['pager']['per_page']);
if ($debug) {
Notice::note("Page: $page \nTotal: $total");
if (isset($data['pager'])) {
$total = round($data['pager']['total'] / $data['pager']['per_page']);
}
$page++;
if (isset($data['results'])) {
foreach ($data['results'] as $event) {
if ($debug && isset($event['HomeTeam'])) {
Notice::note($event['RegionName'].'-'.$event['SportName']."\n".$event['HomeTeam'].' - '.$event['AwayTeam']);
}
$betsapi_id = $event['our_event_id'] ?? 0;
@@ -32,7 +32,7 @@ class Fixtures
$country_map = Country::pluck('id', 'iso2');
$sportmap = Sport::map('bapi', 0, [1]);
$sportmap = Sport::map('bapi', 0, [1, 2, 3, 5]);
$now = Carbon::now();
@@ -8,6 +8,7 @@ use App\Console\Commands\Grapper\Fixtures\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Odds2way;
use App\Models\Odds3way;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -18,27 +19,38 @@ class Willhill
{
$debug = Nuh::$options['d'] ?? 0;
$sport_id = 1;
$sports = [1, 2, 3, 5];
/**
* williamhill
*/
$bookmaker_id = 42;
$collection = [];
$res = Event::with('odds_3ways')
->where('betsapi_id', 0)
->where('sport_id', $sport_id)
->where('starttime', '>', Carbon::now())
->pluck('id');
$res = Odds3way::with('event')->where('bookmaker_id', $bookmaker_id)->get();
foreach ($res as $value) {
if ($value->event->starttime > Carbon::now() && ! $value->event->betsapi_id) {
$collection[] = [
'txodds_id' => $value->event_id,
'willhill_id' => $value->bmoid,
'sport_id' => $value->sport_id,
];
}
}
$res = Odds2way::with('event')->where('bookmaker_id', $bookmaker_id)->get();
foreach ($res as $value) {
if ($value->event->starttime > Carbon::now() && ! $value->event->betsapi_id) {
$collection[] = [
'txodds_id' => $value->event_id,
'willhill_id' => $value->bmoid,
'sport_id' => $value->sport_id,
];
}
}
$events = Odds3way::where('bookmaker_id', $bookmaker_id)
->whereIn('event_id', $res)
->where('bmoid', '!=', 0)
->pluck('event_id', 'bmoid');
foreach ($collection as $event) {
foreach ($events as $willhill_id => $txodds_id) {
$url = 'https://api.b365api.com/v1/williamhill/result?token='.config('env.betsapi_token').'&event_id='.$willhill_id;
$url = 'https://api.b365api.com/v1/williamhill/result?token='.config('env.betsapi_token').'&event_id='.$event['willhill_id'];
$data = Curl::load($url);
@@ -47,17 +59,17 @@ class Willhill
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
if ($debug) {
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
Notice::note(['TXdds ID : '.$event['txodds_id'], "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", 'Willhill ID : '.$event['willhill_id']], 'b');
}
if ($betsapi_id) {
if (isset($data['results'][0]['home'])) {
$match = Event::where('id', (int) $txodds_id)->first();
$match = Event::where('id', (int) $event['txodds_id'])->first();
$ele = [];
$ele['sport_id'] = $sport_id;
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = Nuh::$options['provider_id'];
$ele['element_id'] = $match->home_id ?? 0;
$ele['provider_element_id'] = $data['results'][0]['home']['id'] ?? 0;
@@ -65,7 +77,7 @@ class Willhill
StoreElement::store($elements, $ele);
$ele = [];
$ele['sport_id'] = $sport_id;
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = Nuh::$options['provider_id'];
$ele['element_id'] = $match->away_id ?? 0;
$ele['provider_element_id'] = $data['results'][0]['away']['id'] ?? 0;
@@ -73,7 +85,7 @@ class Willhill
StoreElement::store($elements, $ele);
$group = [];
$group['sport_id'] = $sport_id;
$ele['sport_id'] = $event['sport_id'];
$group['provider_id'] = Nuh::$options['provider_id'];
$group['competition_group_id'] = $match->competition_group_id;
$group['provider_group_id'] = $data['results'][0]['league']['id'] ?? 0;
@@ -17,6 +17,7 @@ class BookmakersTable
->striped()
->recordAction(null)
->columns([
TextColumn::make('id')->searchable(),
TextColumn::make('name')
->searchable(),
BookmakerIcon::make('icon')->label('Icon'),
@@ -15,13 +15,16 @@ use App\Filament\Tables\Columns\ColumnTotal;
use App\Filament\Tables\Columns\ColumnTotalHt;
use App\Filament\Tables\Columns\ColumnTotalQ1;
use App\Filament\Tables\Columns\ColumnTq;
use App\Filament\Tables\Columns\EventColumn;
use App\Filament\Tables\Columns\MatchIds;
use App\Models\BettypeUser;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\EventUserStar;
use App\Models\Group;
use App\Models\MultilineClient;
use App\Models\Sport;
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
@@ -30,6 +33,7 @@ use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Icon;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\VerticalAlignment;
@@ -113,19 +117,11 @@ class EventsTable
TextColumn::make('country.name')
->wrap()
->hidden(fn () => auth()->user()->sport_id == 5)
->color('gray')
->label('Event')
->icon(fn ($record) => $record->country->icon)
->description(fn ($record) => $record->competition_group->name),
->icon(fn ($record) => $record->country?->icon),
TextColumn::make('home.name')
->wrap()
->searchable()
->alignRight(),
TextColumn::make('away.name')
->wrap()
->searchable(),
EventColumn::make('event'),
ColumnMl::make('odds_2ways')->bookmakers(self::$multiline_gettype['odds_2ways'] ?? [])
->visible(fn () => in_array('odds_2ways', self::$bettype_settings))
@@ -218,14 +214,34 @@ class EventsTable
->width(190)
->label('To Qualify'),
])->searchable(['id', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
])->searchable(['id', 'home.name', 'away.name', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
->defaultSort('starttime', 'ASC')
->extremePaginationLinks()
->filters([
Filter::make('events')
->columns(9)->columnSpan(9)
->schema([
Select::make(name: 'sport_id')
->beforeContent(Icon::make(fn () => auth()->user()->sport->icon))
->placeholder('Sport')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->preload()
->options(function () {
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('country_id', null);
$set('competition_group_id', null);
$set('group_id', null);
}),
Select::make(name: 'country_id')
->columnSpan(2)
->hidden(fn () => auth()->user()->sport_id == 5)
->placeholder('Country')
->hiddenLabel()
->label('')
@@ -243,6 +259,7 @@ class EventsTable
$set('competition_group_id', null);
}),
Select::make('competition_group_id')
->hidden(fn () => auth()->user()->sport_id == 5)
->columnSpan(2)
->placeholder('League')
->hiddenLabel()
@@ -264,8 +281,31 @@ class EventsTable
return $arr;
})
->live(),
DateRangePicker::make('starttime_period')
Select::make('group_id')
->columnSpan(2)
->visible(fn () => auth()->user()->sport_id == 5)
->placeholder('Tournament')
->hiddenLabel()
->label('')
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::with('country')->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
} else {
$res = Event::with('country')->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
}
$arr = [];
foreach ($res as $val) {
$arr[$val->group_id] = $val->country?->name.' '.$val->group->name;
}
asort($arr);
return $arr;
})
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(4)
->displayFormat('d M Y')
->minDate(now())
->hiddenLabel()
@@ -281,6 +321,9 @@ class EventsTable
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
)->when(
$data['group_id'],
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
@@ -319,6 +362,15 @@ class EventsTable
}
}
if ($data['group_id'] ?? null) {
$group_ids = Group::whereIn('id', $data['group_id'])->pluck('name')->toArray();
if (count($group_ids) > 1) {
$indicators[] = Indicator::make('Tournament: '.implode(', ', $group_ids))->removeField('group_id');
} else {
$indicators[] = Indicator::make('Tournaments: '.$group_ids[0])->removeField('group_id');
}
}
if ($data['competition_group_id'] ?? null) {
$competition_groups = CompetitionGroup::whereIn('id', $data['competition_group_id'])->pluck('name')->toArray();
if (count($competition_groups) > 1) {
@@ -347,9 +399,8 @@ class EventsTable
}
return $indicators;
})
->columns(2)->columnSpan(2),
], layout: FiltersLayout::Modal)
}),
], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->persistFiltersInSession()
->recordActions([
@@ -0,0 +1,10 @@
<?php
namespace App\Filament\Tables\Columns;
use Filament\Tables\Columns\Column;
class EventColumn extends Column
{
protected string $view = 'filament.tables.columns.event-column';
}