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\Event;
|
||||||
use App\Models\Odds3way;
|
use App\Models\Odds3way;
|
||||||
use App\Models\OddsDc;
|
use App\Models\OddsDc;
|
||||||
|
use App\Models\OddsDnb;
|
||||||
|
use App\Models\OddsGgng;
|
||||||
|
use App\Models\OddsTotal;
|
||||||
use App\Utilities\Margin;
|
use App\Utilities\Margin;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
@@ -34,46 +37,92 @@ class Bet365
|
|||||||
|
|
||||||
$offer = $data['results'][0]['main']['sp'];
|
$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
|
* 1X2
|
||||||
*/
|
*/
|
||||||
$odds = [];
|
if (isset($offer['full_time_result'])) {
|
||||||
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'];
|
$odds = [];
|
||||||
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'];
|
$odds['h3w'] = $offer['full_time_result']['odds'][0]['odds'] ?? 1;
|
||||||
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'];
|
$odds['d3w'] = $offer['full_time_result']['odds'][1]['odds'] ?? 1;
|
||||||
$odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1);
|
$odds['a3w'] = $offer['full_time_result']['odds'][2]['odds'] ?? 1;
|
||||||
$odds['sport_id'] = $event->sport_id;
|
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
|
||||||
$odds['bmoid'] = $event->bet365_id;
|
|
||||||
$odds['flag'] = 1;
|
|
||||||
$odds['last_check_at'] = Carbon::now();
|
|
||||||
|
|
||||||
Odds3way::updateOrCreate([
|
Odds3way::updateOrCreate([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'bookmaker_id' => $bookmaker_id,
|
'bookmaker_id' => $bookmaker_id,
|
||||||
], $odds);
|
], $base + $odds);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DC
|
* DC
|
||||||
*/
|
*/
|
||||||
$odds = [];
|
if (isset($offer['double_chance'])) {
|
||||||
$odds['dc1x'] = $offer['full_time_result']['odds'][0]['odds'];
|
$odds = [];
|
||||||
$odds['dc12'] = $offer['full_time_result']['odds'][1]['odds'];
|
$odds['dc1x'] = $offer['double_chance']['odds'][0]['odds'] ?? 1;
|
||||||
$odds['dcx2'] = $offer['full_time_result']['odds'][2]['odds'];
|
$odds['dc12'] = $offer['double_chance']['odds'][1]['odds'] ?? 1;
|
||||||
$odds['margin'] = (float) Margin::calculate([$odds['dc1x'], $odds['dc12'], $odds['dcx2']], 1);
|
$odds['dcx2'] = $offer['double_chance']['odds'][2]['odds'] ?? 1;
|
||||||
$odds['sport_id'] = $event->sport_id;
|
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
||||||
$odds['provider_id'] = Nuh::$options['provider_id'];
|
|
||||||
$odds['bmoid'] = $event->bet365_id;
|
|
||||||
$odds['flag'] = 1;
|
|
||||||
$odds['last_check_at'] = Carbon::now();
|
|
||||||
|
|
||||||
OddsDc::updateOrCreate([
|
OddsDc::updateOrCreate([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'bookmaker_id' => $bookmaker_id,
|
'bookmaker_id' => $bookmaker_id,
|
||||||
], $odds);
|
], $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\FindEvent;
|
||||||
use App\Mapper\LoadElements;
|
use App\Mapper\LoadElements;
|
||||||
use App\Mapper\LoadGroups;
|
use App\Mapper\LoadGroups;
|
||||||
|
use App\Models\Mapper;
|
||||||
use App\Models\Sport;
|
use App\Models\Sport;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
@@ -23,6 +24,15 @@ class Fixtures
|
|||||||
|
|
||||||
$break = Nuh::$options['b'] ?? 0;
|
$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::$elements = LoadElements::load(Nuh::$options['provider_id']);
|
||||||
|
|
||||||
self::$groups = LoadGroups::load(Nuh::$options['provider_id']);
|
self::$groups = LoadGroups::load(Nuh::$options['provider_id']);
|
||||||
@@ -70,6 +80,7 @@ class Fixtures
|
|||||||
|
|
||||||
$event = [
|
$event = [
|
||||||
'event_id' => (int) $row['id'],
|
'event_id' => (int) $row['id'],
|
||||||
|
'bet365_id' => isset($row['bet365_id']) ? $row['bet365_id'] : 0,
|
||||||
'sport_id' => (int) $sport_id,
|
'sport_id' => (int) $sport_id,
|
||||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use App\Models\Event;
|
|||||||
use App\Models\Mapper;
|
use App\Models\Mapper;
|
||||||
use App\Models\Odds3way;
|
use App\Models\Odds3way;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
class Willhill
|
class Willhill
|
||||||
{
|
{
|
||||||
@@ -53,37 +54,40 @@ class Willhill
|
|||||||
|
|
||||||
if ($betsapi_id) {
|
if ($betsapi_id) {
|
||||||
|
|
||||||
$match = Event::where('id', (int) $txodds_id)->first();
|
if (isset($data['results'][0]['home'])) {
|
||||||
|
|
||||||
$ele = [];
|
$match = Event::where('id', (int) $txodds_id)->first();
|
||||||
$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);
|
|
||||||
|
|
||||||
$ele = [];
|
$ele = [];
|
||||||
$ele['sport_id'] = $sport_id;
|
$ele['sport_id'] = $sport_id;
|
||||||
$ele['provider_id'] = Nuh::$options['provider_id'];
|
$ele['provider_id'] = Nuh::$options['provider_id'];
|
||||||
$ele['element_id'] = $match->away_id ?? 0;
|
$ele['element_id'] = $match->home_id ?? 0;
|
||||||
$ele['provider_element_id'] = $data['results'][0]['away']['id'] ?? 0;
|
$ele['provider_element_id'] = $data['results'][0]['home']['id'] ?? 0;
|
||||||
$ele['name'] = $data['results'][0]['away']['name'];
|
$ele['name'] = $data['results'][0]['home']['name'];
|
||||||
StoreElement::store($elements, $ele);
|
StoreElement::store($elements, $ele);
|
||||||
|
|
||||||
$group = [];
|
$ele = [];
|
||||||
$group['sport_id'] = $sport_id;
|
$ele['sport_id'] = $sport_id;
|
||||||
$group['provider_id'] = Nuh::$options['provider_id'];
|
$ele['provider_id'] = Nuh::$options['provider_id'];
|
||||||
$group['competition_group_id'] = $match->competition_group_id;
|
$ele['element_id'] = $match->away_id ?? 0;
|
||||||
$group['provider_group_id'] = $data['results'][0]['league']['id'] ?? 0;
|
$ele['provider_element_id'] = $data['results'][0]['away']['id'] ?? 0;
|
||||||
$group['name'] = $data['results'][0]['league']['name'];
|
$ele['name'] = $data['results'][0]['away']['name'];
|
||||||
StoreGroup::store($groups, $group);
|
StoreElement::store($elements, $ele);
|
||||||
|
|
||||||
$match->betsapi_id = $betsapi_id;
|
$group = [];
|
||||||
$match->bet365_id = $bet365_id;
|
$group['sport_id'] = $sport_id;
|
||||||
$match->save();
|
$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 CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\ActionGroup;
|
use Filament\Actions\ActionGroup;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
@@ -133,7 +135,7 @@ class EventsTable
|
|||||||
->tooltip(fn ($record) => $record->id)
|
->tooltip(fn ($record) => $record->id)
|
||||||
->visibleFrom('lg'),
|
->visibleFrom('lg'),
|
||||||
|
|
||||||
// MatchIds::make('match_ids')->grow(false)->visibleFrom('xl'),
|
MatchIds::make('match_ids')->grow(false)->visibleFrom('xl'),
|
||||||
|
|
||||||
TextColumn::make('starttime')
|
TextColumn::make('starttime')
|
||||||
->label('Start')
|
->label('Start')
|
||||||
@@ -306,6 +308,10 @@ class EventsTable
|
|||||||
])->iconButton()
|
])->iconButton()
|
||||||
->icon('heroicon-m-ellipsis-vertical')
|
->icon('heroicon-m-ellipsis-vertical')
|
||||||
->color('primary'),
|
->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\Filament\Tables\Columns\MapperLeftColumn;
|
||||||
use App\Mapper\LoadEvents;
|
use App\Mapper\LoadEvents;
|
||||||
|
use App\Mapper\StoreMapped;
|
||||||
use App\Models\CompetitionGroup;
|
use App\Models\CompetitionGroup;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
@@ -31,6 +32,8 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
|||||||
use InteractsWithSchemas;
|
use InteractsWithSchemas;
|
||||||
use InteractsWithTable;
|
use InteractsWithTable;
|
||||||
|
|
||||||
|
public $elements_swopped = false;
|
||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'reload_data' => '$refresh',
|
'reload_data' => '$refresh',
|
||||||
];
|
];
|
||||||
@@ -74,7 +77,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
|||||||
->searchable()
|
->searchable()
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
if ($get('country_id')) {
|
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 {
|
} else {
|
||||||
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
|
$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
|
public function leftAction(): Action
|
||||||
{
|
{
|
||||||
return Action::make('left')
|
return Action::make('left')
|
||||||
->modalHeading('Event Mapper')
|
->modalHeading('Event Mapper')
|
||||||
->modalContent(function (array $arguments) {
|
->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();
|
$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)
|
->modalAlignment(Alignment::Center)
|
||||||
->modalFooterActionsAlignment(Alignment::Center)
|
->modalFooterActionsAlignment(Alignment::Center)
|
||||||
->modalWidth('2xl')
|
->modalWidth('2xl')
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ namespace App\Livewire;
|
|||||||
|
|
||||||
use App\Filament\Tables\Columns\MapperRightColumn;
|
use App\Filament\Tables\Columns\MapperRightColumn;
|
||||||
use App\Mapper\LoadProvider;
|
use App\Mapper\LoadProvider;
|
||||||
|
use App\Mapper\StoreMapped;
|
||||||
|
use App\Models\Country;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use App\Models\Mapper;
|
use App\Models\Mapper;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\Concerns\InteractsWithActions;
|
use Filament\Actions\Concerns\InteractsWithActions;
|
||||||
use Filament\Actions\Contracts\HasActions;
|
use Filament\Actions\Contracts\HasActions;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||||
use Filament\Schemas\Contracts\HasSchemas;
|
use Filament\Schemas\Contracts\HasSchemas;
|
||||||
use Filament\Support\Enums\Alignment;
|
use Filament\Support\Enums\Alignment;
|
||||||
@@ -19,6 +22,8 @@ use Filament\Tables\Enums\FiltersLayout;
|
|||||||
use Filament\Tables\Filters\Filter;
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
|
||||||
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||||
@@ -27,6 +32,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
|||||||
use InteractsWithSchemas;
|
use InteractsWithSchemas;
|
||||||
use InteractsWithTable;
|
use InteractsWithTable;
|
||||||
|
|
||||||
|
public $elements_swopped = false;
|
||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'reload_data' => '$refresh',
|
'reload_data' => '$refresh',
|
||||||
];
|
];
|
||||||
@@ -46,33 +53,45 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
|||||||
->placeholder('Country')
|
->placeholder('Country')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->label('')
|
->label('')
|
||||||
->relationship('country_betsapi', 'name')
|
|
||||||
->searchable()
|
->searchable()
|
||||||
->preload()
|
->preload()
|
||||||
->multiple()
|
->multiple()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->live()
|
->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()
|
->reactive()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('group_id', null);
|
||||||
|
})
|
||||||
->placeholder('Country')
|
->placeholder('Country')
|
||||||
->label('Countries'),
|
->label('Countries'),
|
||||||
Select::make('group_id')
|
Select::make('group_id')
|
||||||
->placeholder('League')
|
->placeholder('League')
|
||||||
|
->label('Leagues')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->label('')
|
->label('')
|
||||||
->options(fn () => Mapper::groupBy('group_id')->pluck('group', 'group_id'))
|
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->searchable()
|
->searchable()
|
||||||
->preload()
|
->preload()
|
||||||
->multiple()
|
->multiple()
|
||||||
->live()
|
->options(function (Get $get) {
|
||||||
->placeholder('League')
|
if ($get('group_cc')) {
|
||||||
->label('Leagues'),
|
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 {
|
->query(function (Builder $query, array $data): Builder {
|
||||||
return $query
|
return $query
|
||||||
->when(
|
->when(
|
||||||
$data['group_cc'],
|
$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(
|
)->when(
|
||||||
$data['group_id'],
|
$data['group_id'],
|
||||||
fn (Builder $query, $group_id) => $query->whereIn('group_id', $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()
|
->hiddenLabel()
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->icon('heroicon-o-arrow-path')
|
->icon('heroicon-o-arrow-path')
|
||||||
// ->icon('phosphor-x')
|
|
||||||
->action(function (Component $livewire) {
|
->action(function (Component $livewire) {
|
||||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||||
$this->tableSearch = ''; // Clears the main search bar
|
$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
|
public function rightAction(): Action
|
||||||
{
|
{
|
||||||
return Action::make('right')
|
return Action::make('right')
|
||||||
->modalHeading('Event Mapper')
|
->modalHeading('Event Mapper')
|
||||||
->modalContent(function (array $arguments) {
|
->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();
|
$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)
|
->modalAlignment(Alignment::Center)
|
||||||
->modalFooterActionsAlignment(Alignment::Center)
|
->modalFooterActionsAlignment(Alignment::Center)
|
||||||
->modalWidth('2xl')
|
->modalWidth('2xl')
|
||||||
|
|||||||
@@ -10,9 +10,14 @@ class FindEvent
|
|||||||
{
|
{
|
||||||
public static function search($event, &$groups, &$elements)
|
public static function search($event, &$groups, &$elements)
|
||||||
{
|
{
|
||||||
|
|
||||||
$event_id = $event['event_id'];
|
$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']);
|
unset($event['event_id']);
|
||||||
|
|
||||||
switch ($event['provider_id']) {
|
switch ($event['provider_id']) {
|
||||||
@@ -40,8 +45,29 @@ class FindEvent
|
|||||||
Notice::note('unknown provider', 'r', 1);
|
Notice::note('unknown provider', 'r', 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($match_id) {
|
if ($match_id) {
|
||||||
|
|
||||||
Mapper::where('event_id', $event_id)->delete();
|
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 {
|
} else {
|
||||||
|
|
||||||
$home_id = $elements[$event['home_id']] ?? 0;
|
$home_id = $elements[$event['home_id']] ?? 0;
|
||||||
@@ -54,22 +80,37 @@ class FindEvent
|
|||||||
|
|
||||||
if ($home_id && $away_id && $cgid) {
|
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()
|
$match_id = Event::query()
|
||||||
->where('home_id', $home_id)
|
->where('home_id', $home_id)
|
||||||
->where('away_id', $away_id)
|
->where('away_id', $away_id)
|
||||||
->where('competition_group_id', $competition_group_id)
|
->where('competition_group_id', $cgid)
|
||||||
->where('starttime', '>', $from)
|
->where('starttime', '>', $from->toDateTimeString())
|
||||||
->where('starttime', '<', $to)
|
->where('starttime', '<', $to->toDateTimeString())
|
||||||
->value('id')
|
->value('id');
|
||||||
->get();
|
|
||||||
|
|
||||||
if ($match_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']) {
|
switch ($event['provider_id']) {
|
||||||
case 2:
|
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 = [
|
protected $fillable = [
|
||||||
'event_id',
|
'event_id',
|
||||||
'provider_id',
|
'betradar_id',
|
||||||
|
'betsapi_id',
|
||||||
|
'bet365_id',
|
||||||
'sport_id',
|
'sport_id',
|
||||||
'tx_id',
|
'provider_id',
|
||||||
'starttime',
|
'starttime',
|
||||||
'group',
|
'group',
|
||||||
'group_id',
|
'group_id',
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ return new class extends Migration
|
|||||||
Schema::create('mappers', function (Blueprint $table) {
|
Schema::create('mappers', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('event_id')->index();
|
$table->integer('event_id')->index();
|
||||||
|
$table->integer('betradar_id')->index();
|
||||||
|
$table->integer('betsapi_id')->index();
|
||||||
|
$table->integer('bet365_id')->index();
|
||||||
$table->integer('sport_id')->index();
|
$table->integer('sport_id')->index();
|
||||||
$table->integer('provider_id')->default(0)->nullable()->index();
|
$table->integer('provider_id')->default(0)->nullable()->index();
|
||||||
$table->dateTime('starttime')->nullable();
|
$table->dateTime('starttime')->nullable();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
const id = event.dataTransfer.getData('text/plain');
|
const id = event.dataTransfer.getData('text/plain');
|
||||||
const target = event.target.closest('li');
|
const target = event.target.closest('li');
|
||||||
if(document.getElementById(id).getAttribute('mapper') !=target.getAttribute('mapper'))
|
if(document.getElementById(id).getAttribute('mapper') !=target.getAttribute('mapper'))
|
||||||
$wire.mountAction('left', { event_id: id, match_id: target.id });"
|
$wire.mountAction('left', { event_id: id, id: target.id });"
|
||||||
draggable="true" mapper="left">
|
draggable="true" mapper="left">
|
||||||
|
|
||||||
<div class="w-10 flex-none mx-auto my-auto">
|
<div class="w-10 flex-none mx-auto my-auto">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<li class="h-full overflow-hidden p-1 cursor-grab flex
|
<li class="w-full h-full overflow-hidden p-1 cursor-grab flex
|
||||||
space-x-4 drag-and-drop__item px-4" x-data="{ moveoverright: false }"
|
space-x-4 drag-and-drop__item px-4"
|
||||||
id={{ $record->event_id }}
|
x-data="{ moveoverright: false }" id={{ $record->event_id }}
|
||||||
x-on:dragstart.self="
|
x-on:dragstart.self="
|
||||||
dragging = true;
|
dragging = true;
|
||||||
event.dataTransfer.effectAllowed = 'move';
|
event.dataTransfer.effectAllowed = 'move';
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
const id = event.dataTransfer.getData('text/plain');
|
const id = event.dataTransfer.getData('text/plain');
|
||||||
const target = event.target.closest('li');
|
const target = event.target.closest('li');
|
||||||
if(document.getElementById(id).getAttribute('mapper') !=target.getAttribute('mapper'))
|
if(document.getElementById(id).getAttribute('mapper') !=target.getAttribute('mapper'))
|
||||||
$wire.mountAction('right', { match_id: id, event_id: target.id });"
|
$wire.mountAction('right', { id: id, event_id: target.id });"
|
||||||
draggable="true" mapper="right">
|
draggable="true" mapper="right">
|
||||||
|
|
||||||
@include('filament.tables.columns.parts.move-botton')
|
@include('filament.tables.columns.parts.move-botton')
|
||||||
|
|||||||
@@ -1,22 +1,80 @@
|
|||||||
|
@php
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
$e = Carbon::parse($event->starttime);
|
||||||
|
$m = Carbon::parse($mapper->starttime);
|
||||||
|
|
||||||
|
$seconds = $e->diffInSeconds($m);
|
||||||
|
|
||||||
|
$diff = gmdate('H:i:s', $seconds);
|
||||||
|
|
||||||
|
if ($seconds == 0) {
|
||||||
|
$color = 1;
|
||||||
|
} elseif ($seconds < 1800) {
|
||||||
|
$color = 2;
|
||||||
|
} elseif ($seconds < 7200) {
|
||||||
|
$color = 3;
|
||||||
|
} else {
|
||||||
|
$color = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
@endphp
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class="grid grid-cols-3 gap-4 text-center">
|
<div class="grid grid-cols-3 gap-4 text-center mt-4 mb-10">
|
||||||
<div>{{ $event->home->name }}</div>
|
<div></div>
|
||||||
|
<div>Startime Difference</div>
|
||||||
|
<div></div>
|
||||||
|
<div class="bg-gray-100 p-1 border rounded-lg">{{ $e->format('d-m-y H:i') }}</div>
|
||||||
|
@switch($color)
|
||||||
|
@case(1)
|
||||||
|
<div class="bg-green-100 text-green-500 p-1 border rounded-lg">{{ $diff }}</div>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case(2)
|
||||||
|
<div class="bg-blue-100 text-blue-500 p-1 border rounded-lg">{{ $diff }}</div>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case(3)
|
||||||
|
<div class="bg-amber-100 text-amber-500 p-1 border rounded-lg">{{ $diff }}</div>
|
||||||
|
@break
|
||||||
|
|
||||||
|
@case(4)
|
||||||
|
<div class="bg-red-100 text-red-500 p-1 border rounded-lg">{{ $diff }}</div>
|
||||||
|
@break
|
||||||
|
@endswitch
|
||||||
|
<div class="bg-gray-100 p-1 border rounded-lg">{{ $m->format('d-m-y H:i') }}</div>
|
||||||
|
<div class="col-span-3 flex justify-center gap-2 mt-6">
|
||||||
|
<div>
|
||||||
|
@if ($event->country?->iso2)
|
||||||
|
<x-icon name="flag-country-{{ $event->country->iso2 }}" class="h5 w-5 mt-1" />
|
||||||
|
@elseif($event->country?->icon)
|
||||||
|
<x-icon name="{{ $event->country->icon }}" class="h5 w-5 mt-1" />
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div>{{ $event->country?->name }}</div>
|
||||||
|
<div>{{ $event->competition_group->name }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pt-2 font-bold text-right">{{ $event->home->name }}</div>
|
||||||
|
|
||||||
<div class="row-span-2 text-center py-auto">
|
<div class="row-span-2 text-center py-auto">
|
||||||
<div x-data="{ open: false, toggle() { this.open = !this.open } }" x-init="open = true">
|
<div x-data="{ elements_swopped: false, toggle() { this.elements_swopped = !this.elements_swopped } }" x-init="elements_swopped = true">
|
||||||
<x-filament::button color="gray" outlined @click="toggle()">
|
<x-filament::button color="gray" outlined @click="toggle()" wire:click="toggle()">
|
||||||
<div x-show="open">
|
<div x-show="elements_swopped">
|
||||||
<x-icon-paralell class="h-16 w-16 mx-auto" />
|
<x-icon-paralell class="h-14 w-14 mx-auto" />
|
||||||
</div>
|
</div>
|
||||||
<div x-show="!open">
|
<div x-show="!elements_swopped">
|
||||||
<x-icon-crossed class="h-16 w-16 mx-auto" />
|
<x-icon-crossed class="h-14 w-14 mx-auto" />
|
||||||
</div>
|
</div>
|
||||||
</x-filament::button>
|
</x-filament::button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ $mapper->home }}</div>
|
|
||||||
|
|
||||||
<div>{{ $event->away->name }}</div>
|
<div class="pt-2 font-bold text-left">{{ $mapper->home }}</div>
|
||||||
|
|
||||||
<div>{{ $mapper->away }}</div>
|
<div class="mb-2 font-bold text-right">{{ $event->away->name }}</div>
|
||||||
|
|
||||||
|
<div class="pb-2 font-bold text-left">{{ $mapper->away }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -74,7 +74,8 @@
|
|||||||
|
|
||||||
{{-- Event Mapper --}}
|
{{-- Event Mapper --}}
|
||||||
|
|
||||||
<x-filament::modal width="7xl" icon="heroicon-o-squares-2x2">
|
<x-filament::modal width="7xl" icon="heroicon-o-squares-2x2" :close-by-clicking-away="false" :close-by-escaping="false"
|
||||||
|
:close-button="true">
|
||||||
<x-slot name="trigger">
|
<x-slot name="trigger">
|
||||||
<x-filament::button outlined icon="heroicon-o-squares-2x2" color="gray">
|
<x-filament::button outlined icon="heroicon-o-squares-2x2" color="gray">
|
||||||
Event Mapper
|
Event Mapper
|
||||||
|
|||||||
Reference in new issue
Block a user