grapper betsapi ok
This commit is contained in:
1 parent
b1a724061f
commit
34690292aa
15 files changed
+1751
-97
No files matched your search
@@ -7,6 +7,9 @@ use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\OddsDc;
|
||||
use App\Models\OddsDnb;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@@ -34,46 +37,92 @@ class Bet365
|
||||
|
||||
$offer = $data['results'][0]['main']['sp'];
|
||||
|
||||
$base = [];
|
||||
$base['sport_id'] = $event->sport_id;
|
||||
$base['provider_id'] = Nuh::$options['provider_id'];
|
||||
$base['bmoid'] = $event->bet365_id;
|
||||
$base['flag'] = 1;
|
||||
$base['last_check_at'] = Carbon::now();
|
||||
|
||||
/**
|
||||
* 1X2
|
||||
*/
|
||||
$odds = [];
|
||||
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'];
|
||||
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'];
|
||||
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'];
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
|
||||
$odds['sport_id'] = $event->sport_id;
|
||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
||||
$odds['bmoid'] = $event->bet365_id;
|
||||
$odds['flag'] = 1;
|
||||
$odds['last_check_at'] = Carbon::now();
|
||||
if (isset($offer['full_time_result'])) {
|
||||
$odds = [];
|
||||
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'] ?? 1;
|
||||
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'] ?? 1;
|
||||
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'] ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $odds);
|
||||
Odds3way::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $base + $odds);
|
||||
}
|
||||
|
||||
/**
|
||||
* DC
|
||||
*/
|
||||
$odds = [];
|
||||
$odds['dc1x'] = $offer['full_time_result']['odds'][0]['odds'];
|
||||
$odds['dc12'] = $offer['full_time_result']['odds'][1]['odds'];
|
||||
$odds['dcx2'] = $offer['full_time_result']['odds'][2]['odds'];
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['dc1x'], $odds['dc12'], $odds['dcx2']], 1);
|
||||
$odds['sport_id'] = $event->sport_id;
|
||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
||||
$odds['bmoid'] = $event->bet365_id;
|
||||
$odds['flag'] = 1;
|
||||
$odds['last_check_at'] = Carbon::now();
|
||||
if (isset($offer['double_chance'])) {
|
||||
$odds = [];
|
||||
$odds['dc1x'] = $offer['double_chance']['odds'][0]['odds'] ?? 1;
|
||||
$odds['dc12'] = $offer['double_chance']['odds'][1]['odds'] ?? 1;
|
||||
$odds['dcx2'] = $offer['double_chance']['odds'][2]['odds'] ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $odds);
|
||||
OddsDc::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $base + $odds);
|
||||
}
|
||||
|
||||
dd($odds);
|
||||
/**
|
||||
* OU
|
||||
*/
|
||||
if (isset($offer['goals_over_under'])) {
|
||||
$odds = [];
|
||||
$odds['over'] = $offer['goals_over_under']['odds'][0]['odds'] ?? 1;
|
||||
$odds['under'] = $offer['goals_over_under']['odds'][1]['odds'] ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
if ((float) $offer['goals_over_under']['odds'][1]['name'] == 2.5) {
|
||||
OddsTotal::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
'total' => 2.5,
|
||||
], $base + $odds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GG NG
|
||||
*/
|
||||
if (isset($offer['both_teams_to_score'])) {
|
||||
$odds = [];
|
||||
$odds['gg'] = $offer['both_teams_to_score']['odds'][0]['odds'] ?? 1;
|
||||
$odds['ng'] = $offer['both_teams_to_score']['odds'][1]['odds'] ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
OddsGgng::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $base + $odds);
|
||||
}
|
||||
|
||||
/**
|
||||
* DNB
|
||||
*/
|
||||
if (isset($offer['draw_no_bet'])) {
|
||||
$odds = [];
|
||||
$odds['dnb1'] = $offer['draw_no_bet']['odds'][0]['odds'] ?? 1;
|
||||
$odds['dnb2'] = $offer['draw_no_bet']['odds'][1]['odds'] ?? 1;
|
||||
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||
|
||||
OddsDnb::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], $base + $odds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use App\Console\Commands\Nuh;
|
||||
use App\Mapper\FindEvent;
|
||||
use App\Mapper\LoadElements;
|
||||
use App\Mapper\LoadGroups;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -23,6 +24,15 @@ class Fixtures
|
||||
|
||||
$break = Nuh::$options['b'] ?? 0;
|
||||
|
||||
/**
|
||||
* Delete Started
|
||||
*/
|
||||
$info = Mapper::where('starttime', '<', Carbon::now()->toDateTimeString())->delete();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Deleted: $info");
|
||||
}
|
||||
|
||||
self::$elements = LoadElements::load(Nuh::$options['provider_id']);
|
||||
|
||||
self::$groups = LoadGroups::load(Nuh::$options['provider_id']);
|
||||
@@ -70,6 +80,7 @@ class Fixtures
|
||||
|
||||
$event = [
|
||||
'event_id' => (int) $row['id'],
|
||||
'bet365_id' => isset($row['bet365_id']) ? $row['bet365_id'] : 0,
|
||||
'sport_id' => (int) $sport_id,
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Odds3way;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Willhill
|
||||
{
|
||||
@@ -53,37 +54,40 @@ class Willhill
|
||||
|
||||
if ($betsapi_id) {
|
||||
|
||||
$match = Event::where('id', (int) $txodds_id)->first();
|
||||
if (isset($data['results'][0]['home'])) {
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $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;
|
||||
$ele['name'] = $data['results'][0]['home']['name'];
|
||||
StoreElement::store($elements, $ele);
|
||||
$match = Event::where('id', (int) $txodds_id)->first();
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $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;
|
||||
$ele['name'] = $data['results'][0]['away']['name'];
|
||||
StoreElement::store($elements, $ele);
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $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;
|
||||
$ele['name'] = $data['results'][0]['home']['name'];
|
||||
StoreElement::store($elements, $ele);
|
||||
|
||||
$group = [];
|
||||
$group['sport_id'] = $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;
|
||||
$group['name'] = $data['results'][0]['league']['name'];
|
||||
StoreGroup::store($groups, $group);
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $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;
|
||||
$ele['name'] = $data['results'][0]['away']['name'];
|
||||
StoreElement::store($elements, $ele);
|
||||
|
||||
$match->betsapi_id = $betsapi_id;
|
||||
$match->bet365_id = $bet365_id;
|
||||
$match->save();
|
||||
$group = [];
|
||||
$group['sport_id'] = $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;
|
||||
$group['name'] = $data['results'][0]['league']['name'];
|
||||
StoreGroup::store($groups, $group);
|
||||
|
||||
Mapper::where('event_id', $betsapi_id)->delete();
|
||||
$match->betsapi_id = $betsapi_id;
|
||||
$match->bet365_id = $bet365_id;
|
||||
$match->save();
|
||||
|
||||
Mapper::where('event_id', $betsapi_id)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -16,7 +16,9 @@ use App\Models\MultilineClient;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -133,7 +135,7 @@ class EventsTable
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
|
||||
// MatchIds::make('match_ids')->grow(false)->visibleFrom('xl'),
|
||||
MatchIds::make('match_ids')->grow(false)->visibleFrom('xl'),
|
||||
|
||||
TextColumn::make('starttime')
|
||||
->label('Start')
|
||||
@@ -306,6 +308,10 @@ class EventsTable
|
||||
])->iconButton()
|
||||
->icon('heroicon-m-ellipsis-vertical')
|
||||
->color('primary'),
|
||||
])->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\MapperLeftColumn;
|
||||
use App\Mapper\LoadEvents;
|
||||
use App\Mapper\StoreMapped;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
@@ -31,6 +32,8 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $elements_swopped = false;
|
||||
|
||||
protected $listeners = [
|
||||
'reload_data' => '$refresh',
|
||||
];
|
||||
@@ -74,7 +77,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->where('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
|
||||
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
|
||||
} else {
|
||||
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
|
||||
}
|
||||
@@ -123,17 +126,29 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
]);
|
||||
}
|
||||
|
||||
public function toggle()
|
||||
{
|
||||
$this->elements_swopped = ! $this->elements_swopped;
|
||||
}
|
||||
|
||||
public function leftAction(): Action
|
||||
{
|
||||
return Action::make('left')
|
||||
->modalHeading('Event Mapper')
|
||||
->modalContent(function (array $arguments) {
|
||||
$event = Event::where('id', $arguments['match_id'])->first();
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper, 'mappermode' => 'linear']);
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
|
||||
})
|
||||
->action(function ($arguments) {
|
||||
StoreMapped::store($arguments, $this->elements_swopped);
|
||||
})
|
||||
->closeModalByEscaping(false)
|
||||
->modalCloseButton(false)
|
||||
->closeModalByClickingAway(false)
|
||||
->modalAlignment(Alignment::Center)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->modalWidth('2xl')
|
||||
|
||||
@@ -4,12 +4,15 @@ namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\MapperRightColumn;
|
||||
use App\Mapper\LoadProvider;
|
||||
use App\Mapper\StoreMapped;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
@@ -19,6 +22,8 @@ use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
@@ -27,6 +32,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $elements_swopped = false;
|
||||
|
||||
protected $listeners = [
|
||||
'reload_data' => '$refresh',
|
||||
];
|
||||
@@ -46,33 +53,45 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->relationship('country_betsapi', 'name')
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->columnSpan(2)
|
||||
->live()
|
||||
->options(function () {
|
||||
$res = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray();
|
||||
|
||||
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country')
|
||||
->label('Countries'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->options(fn () => Mapper::groupBy('group_id')->pluck('group', 'group_id'))
|
||||
->columnSpan(2)
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->live()
|
||||
->placeholder('League')
|
||||
->label('Leagues'),
|
||||
->options(function (Get $get) {
|
||||
if ($get('group_cc')) {
|
||||
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
|
||||
} else {
|
||||
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
|
||||
}
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['group_cc'],
|
||||
fn (Builder $query, $group_cc) => $query->where('group_cc', $group_cc)
|
||||
fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
|
||||
)->when(
|
||||
$data['group_id'],
|
||||
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
|
||||
@@ -89,7 +108,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->hiddenLabel()
|
||||
->color('gray')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
// ->icon('phosphor-x')
|
||||
->action(function (Component $livewire) {
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
@@ -97,16 +115,28 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
]);
|
||||
}
|
||||
|
||||
public function toggle()
|
||||
{
|
||||
$this->elements_swopped = ! $this->elements_swopped;
|
||||
}
|
||||
|
||||
public function rightAction(): Action
|
||||
{
|
||||
return Action::make('right')
|
||||
->modalHeading('Event Mapper')
|
||||
->modalContent(function (array $arguments) {
|
||||
$event = Event::where('id', $arguments['match_id'])->first();
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper, 'mappermode' => 'linear']);
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
|
||||
})->action(function ($arguments) {
|
||||
StoreMapped::store($arguments, $this->elements_swopped);
|
||||
})
|
||||
->closeModalByEscaping(false)
|
||||
->modalCloseButton(false)
|
||||
->closeModalByClickingAway(false)
|
||||
->modalAlignment(Alignment::Center)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->modalWidth('2xl')
|
||||
|
||||
@@ -10,9 +10,14 @@ class FindEvent
|
||||
{
|
||||
public static function search($event, &$groups, &$elements)
|
||||
{
|
||||
|
||||
$event_id = $event['event_id'];
|
||||
|
||||
$betradar_id = $event['betradar_id'] ?? 0;
|
||||
|
||||
$betsapi_id = $event['betsapi_id'] ?? 0;
|
||||
|
||||
$bet365_id = $event['bet365_id'] ?? 0;
|
||||
|
||||
unset($event['event_id']);
|
||||
|
||||
switch ($event['provider_id']) {
|
||||
@@ -40,8 +45,29 @@ class FindEvent
|
||||
Notice::note('unknown provider', 'r', 1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($match_id) {
|
||||
|
||||
Mapper::where('event_id', $event_id)->delete();
|
||||
|
||||
$event = Event::where('id', $match_id)->first();
|
||||
|
||||
$update_array = [];
|
||||
|
||||
if ($betradar_id && ! $event->betradar_id) {
|
||||
$update_array['betradar_id'] = $betradar_id;
|
||||
}
|
||||
if ($betsapi_id && ! $event->betsapi_id) {
|
||||
$update_array['betsapi_id'] = $betsapi_id;
|
||||
}
|
||||
if ($bet365_id && ! $event->bet365_id) {
|
||||
$update_array['bet365_id'] = $bet365_id;
|
||||
}
|
||||
|
||||
if ($update_array) {
|
||||
Event::where('id', $match_id)->update($update_array);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
|
||||
$home_id = $elements[$event['home_id']] ?? 0;
|
||||
@@ -54,22 +80,37 @@ class FindEvent
|
||||
|
||||
if ($home_id && $away_id && $cgid) {
|
||||
|
||||
$from = Carbon::createFromDate($startime)->remvoDay();
|
||||
$from = Carbon::createFromDate($startime)->subDay();
|
||||
|
||||
$to = Carbon::createFromDate($starttime_period['end'])->subDay();
|
||||
$to = Carbon::createFromDate($startime)->addDay();
|
||||
|
||||
// dd($home_id, $away_id, $cgid, $from->toDateTimeString(), $to->toDateTimeString());
|
||||
|
||||
$match_id = Event::query()
|
||||
->where('home_id', $home_id)
|
||||
->where('away_id', $away_id)
|
||||
->where('competition_group_id', $competition_group_id)
|
||||
->where('starttime', '>', $from)
|
||||
->where('starttime', '<', $to)
|
||||
->value('id')
|
||||
->get();
|
||||
->where('competition_group_id', $cgid)
|
||||
->where('starttime', '>', $from->toDateTimeString())
|
||||
->where('starttime', '<', $to->toDateTimeString())
|
||||
->value('id');
|
||||
|
||||
if ($match_id) {
|
||||
|
||||
Event::where('betsapi_id', (int) $betsapi_id)->update(['betradar_id' => $betradar_id, 'bwin_id' => $bwin_id]);
|
||||
$update_array = [];
|
||||
|
||||
if ($betradar_id) {
|
||||
$update_array['betradar_id'] = $betradar_id;
|
||||
}
|
||||
if ($betsapi_id) {
|
||||
$update_array['betsapi_id'] = $betsapi_id;
|
||||
}
|
||||
if ($bet365_id) {
|
||||
$update_array['bet365_id'] = $bet365_id;
|
||||
}
|
||||
|
||||
if ($update_array) {
|
||||
Event::where('id', $match_id)->update($update_array);
|
||||
}
|
||||
|
||||
switch ($event['provider_id']) {
|
||||
case 2:
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mapper;
|
||||
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
use App\Models\ElementProvider;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreMapped
|
||||
{
|
||||
public static function store($arguments, $swopped)
|
||||
{
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
/*
|
||||
EVENT
|
||||
"id" => 14039120
|
||||
"provider_id" => 1
|
||||
"betsapi_id" => 0
|
||||
"betradar_id" => 0
|
||||
"bet365_id" => 0
|
||||
"_1xbet_id" => 0
|
||||
"bwin_id" => 0
|
||||
"magnig_id" => 0
|
||||
"magken_id" => 0
|
||||
"lognig_id" => 0
|
||||
"logcol_id" => 0
|
||||
"starttime" => "2026-01-02 13:00:00"
|
||||
"sport_id" => 1
|
||||
"country_id" => 365
|
||||
"group_id" => 177539
|
||||
"competition_group_id" => 141
|
||||
"home_id" => 6963
|
||||
"away_id" => 6844
|
||||
MAPPER
|
||||
"id" => 1
|
||||
"event_id" => 11208805
|
||||
"sport_id" => 1
|
||||
"provider_id" => 2
|
||||
"starttime" => "2026-01-02 05:00:00"
|
||||
"group" => "Indonesia Liga 4"
|
||||
"group_id" => 39616
|
||||
"group_cc" => "ID"
|
||||
"home" => "Boliyohuto FC"
|
||||
"home_id" => 308421
|
||||
"home_cc" => "ID"
|
||||
"away" => "Panipi Raya FC"
|
||||
"away_id" => 308005
|
||||
"away_cc" => "ID"
|
||||
"created_at" => "2026-01-02 06:33:20"
|
||||
"updated_at" => "2026-01-02 06:33:20"
|
||||
*/
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->home_id ?? 0;
|
||||
$ele['name'] = $mapper->home;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->home_id], $ele);
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->away_id ?? 0;
|
||||
$ele['name'] = $mapper->away;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->away_id], $ele);
|
||||
|
||||
$group['sport_id'] = $event->sport_id;
|
||||
$group['provider_id'] = Auth::user()->provider_id;
|
||||
$group['competition_group_id'] = $event->competition_group_id;
|
||||
$group['name'] = $mapper->group;
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $mapper->group_id], $group);
|
||||
|
||||
switch ($mapper->provider_id) {
|
||||
case 2:
|
||||
// BETSAPI
|
||||
$event->betradar_id = $mapper->betradar_id ?? 0;
|
||||
$event->betsapi_id = $mapper->event_id;
|
||||
$event->bet365_id = $mapper->bet365_id ?? 0;
|
||||
break;
|
||||
case 3:
|
||||
// MAGLOO KENIA
|
||||
$event->magnig_id = $mapper->event_id;
|
||||
break;
|
||||
case 4:
|
||||
// MAGLOO NIGERIA
|
||||
$event->magken_id = $mapper->event_id;
|
||||
break;
|
||||
case 5:
|
||||
// LOGIFUTUR NIGERA
|
||||
$event->lognig_id = $mapper->event_id;
|
||||
break;
|
||||
case 6:
|
||||
// LOGIFUTUR COLOMBIA
|
||||
$event->logcol_id = $mapper->event_id;
|
||||
break;
|
||||
}
|
||||
$event->save();
|
||||
|
||||
Mapper::where('event_id', $arguments['event_id'])->delete();
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,11 @@ class Mapper extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'event_id',
|
||||
'provider_id',
|
||||
'betradar_id',
|
||||
'betsapi_id',
|
||||
'bet365_id',
|
||||
'sport_id',
|
||||
'tx_id',
|
||||
'provider_id',
|
||||
'starttime',
|
||||
'group',
|
||||
'group_id',
|
||||
|
||||
Reference in new issue
Block a user