mapper wip
This commit is contained in:
1 parent
ba6c2263e3
commit
02712ec610
27 files changed
+1070
-158
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Betsapi\Fixtures;
|
||||
use App\Console\Commands\Grapper\Betsapi\IdMapper;
|
||||
use App\Console\Commands\Grapper\Betsapi\Odds;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Betsapi
|
||||
{
|
||||
public static function switch()
|
||||
{
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'Fixtures':
|
||||
Fixtures::grap();
|
||||
break;
|
||||
case 'Odds':
|
||||
Odds::grap();
|
||||
break;
|
||||
case 'IdMapper':
|
||||
IdMapper::grap();
|
||||
break;
|
||||
default:
|
||||
Notice::note('prosses name does not exist', 'r', 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Fixtures
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$test = Nuh::$options['t'] ?? 0;
|
||||
$echo = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('bapi');
|
||||
|
||||
$total = 10;
|
||||
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
|
||||
$page = 1;
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = "https://api.b365api.com/v3/events/upcoming?sport_id=$betsapi_sport_id&page=$page&skip_esports=1&token=".config('env.betsapi_token');
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$page++;
|
||||
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
if (isset($data['results'])) {
|
||||
|
||||
foreach ($data['results'] as $row) {
|
||||
|
||||
$event = [
|
||||
'sport_id' => (int) $row['sport_id'],
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||
'home' => $row['home']['name'] ?? '',
|
||||
'home_id' => (int) $row['home']['id'],
|
||||
'home_cc' => $row['home']['cc'] ?? '',
|
||||
'away' => $row['away']['name'] ?? '',
|
||||
'away_id' => (int) $row['away']['id'],
|
||||
'away_cc' => $row['away']['cc'] ?? '',
|
||||
'group' => $row['league']['name'] ?? '',
|
||||
'group_id' => (int) $row['league']['id'] ?? 0,
|
||||
'group_cc' => $row['league']['cc'] ?? '',
|
||||
];
|
||||
|
||||
Mapper::updateOrCreate(['betsapi_id' => (int) $row['id']], $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('FIRST LOOP', 'g', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Mapper;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class IdMapper
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$test = Nuh::$options['t'] ?? 0;
|
||||
$echo = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$total = 10;
|
||||
|
||||
$bookmakers = [[
|
||||
'name' => 'betfair',
|
||||
'url' => 'https://api.b365api.com/v1/betfair/sb/upcoming?sport_id=###sport_id###&page=###page###',
|
||||
], [
|
||||
'name' => '1xbet',
|
||||
'url' => 'https://api.b365api.com/v1/1xbet/upcoming?sport_id=###sport_id###&page=###page###',
|
||||
]];
|
||||
|
||||
foreach ($bookmakers as $bookmaker) {
|
||||
|
||||
if ($bookmaker['name'] == '1xbet') {
|
||||
// same like txodds
|
||||
$sportmap = [1, 2, 3];
|
||||
} elseif ($bookmaker['name'] == 'betfair') {
|
||||
// 1 soccer
|
||||
// 7522 basketball
|
||||
$sportmap = [1, 7522];
|
||||
}
|
||||
|
||||
foreach ($sportmap as $sport_id) {
|
||||
|
||||
$page = 1;
|
||||
|
||||
$url = str_replace('###sport_id###', $sport_id, $bookmaker['url']).'&token='.config('env.betsapi_token');
|
||||
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = str_replace('###page###', $page, $url);
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$page++;
|
||||
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
if (isset($data['results'])) {
|
||||
|
||||
foreach ($data['results'] as $row) {
|
||||
if ($bookmaker['name'] == '1xbet') {
|
||||
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['_1xbet_id' => (int) $row['id']]);
|
||||
} elseif ($bookmaker['name'] == 'betfair') {
|
||||
Mapper::where('betsapi_id', (int) $row['our_event_id'])->update(['betfairsb_id' => (int) $row['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
class Odds
|
||||
{
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
6 Unibet
|
||||
13 Sportingbet
|
||||
42 William Hill
|
||||
110 BetFair
|
||||
117 SNAI
|
||||
314 Matchbook
|
||||
649 1XBet
|
||||
824 BetPlay
|
||||
@@ -61,6 +61,7 @@ class Fixtures
|
||||
// </match>
|
||||
$event = [];
|
||||
$event['tx_id'] = (int) $row['id'];
|
||||
$event['provider_id'] = (int) Nuh::$options['provider_id'];
|
||||
$event['starttime'] = Carbon::createFromDate((string) $row->time)->toDateTimeString();
|
||||
$group_name = (string) $row->group;
|
||||
$event['group_id'] = (int) $row->group['id'];
|
||||
|
||||
@@ -260,7 +260,6 @@ class Odds
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('END '.Nuh::$_event->id, 'g');
|
||||
Notice::note('END', 'g');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Commands\Grapper\Betsapi;
|
||||
use App\Console\Commands\Grapper\Magloo;
|
||||
use App\Console\Commands\Grapper\TxOdds;
|
||||
use App\Models\Supervisor;
|
||||
@@ -83,14 +84,16 @@ class Nuh extends Command
|
||||
switch (self::$options['provider_id']) {
|
||||
case 1:
|
||||
TxOdds::switch();
|
||||
break;
|
||||
case 2:
|
||||
// betsapi
|
||||
Betsapi::switch();
|
||||
break;
|
||||
case 3:
|
||||
// MAGLOO KENIA
|
||||
// Kenia
|
||||
Magloo::switch();
|
||||
break;
|
||||
case 4:
|
||||
// MAGLOO NIGERIA
|
||||
// Nigeria
|
||||
Magloo::switch();
|
||||
break;
|
||||
case 5:
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\EventMapper;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class EventMapperCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2;
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\CompetitionGroupFilters;
|
||||
|
||||
use App\Filament\Clusters\EventMapper\EventMapperCluster;
|
||||
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||
use App\Filament\Resources\CompetitionGroupFilters\Pages\CreateCompetitionGroupFilter;
|
||||
use App\Filament\Resources\CompetitionGroupFilters\Pages\EditCompetitionGroupFilter;
|
||||
use App\Filament\Resources\CompetitionGroupFilters\Pages\ListCompetitionGroupFilters;
|
||||
@@ -24,7 +24,7 @@ class CompetitionGroupFilterResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = EventMapperCluster::class;
|
||||
protected static ?string $cluster = SettingsCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Filter';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\ElementFilters;
|
||||
|
||||
use App\Filament\Clusters\EventMapper\EventMapperCluster;
|
||||
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||
use App\Filament\Resources\ElementFilters\Pages\CreateElementFilter;
|
||||
use App\Filament\Resources\ElementFilters\Pages\EditElementFilter;
|
||||
use App\Filament\Resources\ElementFilters\Pages\ListElementFilters;
|
||||
@@ -24,7 +24,7 @@ class ElementFilterResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = EventMapperCluster::class;
|
||||
protected static ?string $cluster = SettingsCluster::class;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Filter';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\GroupFilters;
|
||||
|
||||
use App\Filament\Clusters\EventMapper\EventMapperCluster;
|
||||
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||
use App\Filament\Resources\GroupFilters\Pages\ListGroupFilters;
|
||||
use App\Filament\Resources\GroupFilters\Schemas\GroupFilterForm;
|
||||
use App\Filament\Resources\GroupFilters\Tables\GroupFiltersTable;
|
||||
@@ -21,7 +21,7 @@ class GroupFilterResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $cluster = EventMapperCluster::class;
|
||||
protected static ?string $cluster = SettingsCluster::class;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Filter';
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Filament\Resources\Supervisors\Schemas;
|
||||
use App\Models\Sport;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SupervisorForm
|
||||
@@ -14,20 +13,21 @@ class SupervisorForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Toggle::make('is_cron')->columns(2),
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
Select::make('provider_id')
|
||||
->relationship('provider', 'name')
|
||||
->required()
|
||||
->preload(),
|
||||
Select::make('sport_id')
|
||||
->options(Sport::query()->where('is_active', 1)->pluck('name', 'id'))
|
||||
->options(function () {
|
||||
$res = Sport::where('is_active', 1)->pluck('name', 'id')->toArray();
|
||||
array_unshift($res, 'All');
|
||||
|
||||
return $res;
|
||||
})
|
||||
->nullable(),
|
||||
|
||||
TextInput::make('sleep'),
|
||||
TextInput::make('maxsconds')->label('Seconds till throwing an error'),
|
||||
TextInput::make('sleep')->default(15),
|
||||
TextInput::make('maxsconds')->label('Seconds till throwing an error')->default(1800),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ class SupervisorsTable
|
||||
->options([
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'IdMapper' => 'IdMapper',
|
||||
]),
|
||||
TextColumn::make('provider.name')->badge(),
|
||||
TextColumn::make('sport.name')->label('Sport'),
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Mapper;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperClients extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(fn (): Builder => Mapper::query())
|
||||
->columns([
|
||||
TextColumn::make('home')->searchable()->alignRight(),
|
||||
TextColumn::make('away')->searchable(),
|
||||
TextColumn::make('group')->searchable()->wrap(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
//
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
//
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.mapper-clients');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Event;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperEvents extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(fn (): Builder => Event::query())
|
||||
->columns([
|
||||
// TextColumn::make('country.name')
|
||||
// ->color('gray')
|
||||
// ->label('Event')
|
||||
// ->icon(fn ($record) => $record->country->icon)
|
||||
// ->description(fn ($record) => $record->competition_group->name)
|
||||
// ->wrap(),
|
||||
TextColumn::make('competition_group.name')->searchable()->wrap(),
|
||||
TextColumn::make('home.name')->searchable()->alignRight(),
|
||||
TextColumn::make('away.name')->searchable(),
|
||||
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->headerActions([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
//
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
//
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.mapper-events');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Mapper extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'sport_id',
|
||||
'provider_id',
|
||||
'tx_id',
|
||||
'betradar_id',
|
||||
'betradar_id',
|
||||
'betsapi_id',
|
||||
'bet365_id',
|
||||
'_1xbet_id',
|
||||
'betfairsb_id',
|
||||
'starttime',
|
||||
'group',
|
||||
'group_id',
|
||||
'group_cc',
|
||||
'home',
|
||||
'home_id',
|
||||
'home_cc',
|
||||
'away',
|
||||
'away_id',
|
||||
'away_cc',
|
||||
];
|
||||
}
|
||||
@@ -7,13 +7,13 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Sport extends Model
|
||||
{
|
||||
public static function map($field)
|
||||
public static function map($field, $_limit = [])
|
||||
{
|
||||
if (! in_array($field, ['bapi', 'bwin', 'b365', 'logi', 'magl'])) {
|
||||
Notice::note('Wrong Option! Possible options: bapi, bwin, b365, logi, magl', 'r', 1);
|
||||
Notice::note('Sport::map wrong option! Possible options: bapi, bwin, b365, logi, magl', 'r', 1);
|
||||
}
|
||||
|
||||
return Sport::where('is_active', 1)->pluck($field, 'id')->toArray();
|
||||
return Sport::where('is_active', 1)->whereNotIn('id', $_limit)->pluck($field, 'id')->toArray();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user