mapper wip

This commit is contained in:
salam committed 2025-12-28 13:59:37 +01:00
1 parent 80f50c9eec
commit 55c404c17a
9 files changed
+111 -48

No files matched your search

+3 -2
View File
@@ -29,10 +29,11 @@ class MultilineGenerator
'client_id' => $client_id,
'sport_id' => $sportid,
'multiline_setting_id' => $multiline->id,
'sort' => $i,
'bookmaker_id' => $bookmaker[$i],
'position' => $i,
],
[
'bookmaker_id' => $bookmaker[$i],
'sort' => $i,
'disabled' => 0,
]
);
@@ -26,7 +26,7 @@ class Fixtures
Notice::note('Day: '.$now->format('d. M Y'), 'g');
}
$base_url = 'https://api.b365api.com/v3/events/upcoming?sport_id=###sport_id###&page=###page###&day='.$now->format('Ymd').'skip_esports=1&token='.config('env.betsapi_token');
$base_url = 'https://api.b365api.com/v3/events/upcoming?sport_id=###sport_id###&page=###page###&day='.$now->format('Ymd').'&skip_esports=1&token='.config('env.betsapi_token');
$now->addDays(1);
@@ -44,34 +44,36 @@ class Fixtures
$page++;
$total = round($data['pager']['total'] / $data['pager']['per_page']);
if (isset($data['pager']['total'])) {
$total = round($data['pager']['total'] / $data['pager']['per_page']);
if ($debug) {
Notice::note("Page: $page \nTotal: $total");
}
if ($debug) {
Notice::note("Page: $page \nTotal: $total");
}
if (isset($data['results'])) {
if (isset($data['results']) && count($data['results'])) {
foreach ($data['results'] as $row) {
foreach ($data['results'] as $row) {
if (isset($row['home']['id']) && isset($row['away']['id']) && strpos($row['league']['name'], 'Esoccer') === false) {
if (isset($row['home']['id']) && isset($row['away']['id']) && strpos($row['league']['name'], 'Esoccer') === false) {
$event = [
'sport_id' => (int) $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' => strtoupper($row['home']['cc']) ?? '',
'away' => $row['away']['name'] ?? '',
'away_id' => (int) $row['away']['id'],
'away_cc' => strtoupper($row['away']['cc']) ?? '',
'group' => $row['league']['name'] ?? '',
'group_id' => (int) $row['league']['id'] ?? 0,
'group_cc' => strtoupper($row['league']['cc']) ?? '',
];
$event = [
'sport_id' => (int) $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' => strtoupper($row['home']['cc']) ?? '',
'away' => $row['away']['name'] ?? '',
'away_id' => (int) $row['away']['id'],
'away_cc' => strtoupper($row['away']['cc']) ?? '',
'group' => $row['league']['name'] ?? '',
'group_id' => (int) $row['league']['id'] ?? 0,
'group_cc' => strtoupper($row['league']['cc']) ?? '',
];
Mapper::updateOrCreate(['event_id' => (int) $row['id']], $event);
Mapper::updateOrCreate(['event_id' => (int) $row['id']], $event);
}
}
}
}
@@ -131,7 +131,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')
@@ -235,7 +235,7 @@ class EventsTable
}
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name;
$arr[$val->competition_group_id] = $val->country?->name.' - '.$val->competition_group->name;
}
asort($arr);
@@ -247,7 +247,7 @@ class EventsTable
return $query
->when(
$data['country_id'],
fn (Builder $query, $sport_id) => $query->where('country_id', $sport_id)
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
+38 -8
View File
@@ -5,6 +5,7 @@ namespace App\Livewire;
use App\Filament\Tables\Columns\MapperLeftColumn;
use App\Models\Event;
use App\Models\Mapper;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -13,7 +14,10 @@ use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Alignment;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Component;
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
@@ -25,17 +29,43 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
return $table
->query(Event::query())
->query(Event::query()->where('betradar_id', 0))
->columns([
MapperLeftColumn::make('left')->label('NUH-ODDS'),
])
MapperLeftColumn::make('left')->label(''),
])->searchable(['home.name', 'away.name'])
->defaultPaginationPageOption(5)
->filters([
// ...
])
->recordActions([
// ...
])
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())
)
->searchable()
->preload()
->multiple()
->placeholder('Country')
->label('Countries'),
SelectFilter::make('competition_group_id')
->options(function () {
$res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group->name;
}
asort($arr);
return $arr;
})
->columnSpan(2)
->searchable()
->preload()
->multiple()
->placeholder('League')
->label('Leagues'),
], layout: FiltersLayout::AboveContent)
->hiddenFilterIndicators()
->filtersFormColumns(3)
->deferFilters(false)
->toolbarActions([
// ...
]);
+23 -7
View File
@@ -13,6 +13,8 @@ use Filament\Schemas\Contracts\HasSchemas;
use Filament\Support\Enums\Alignment;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Livewire\Component;
@@ -27,15 +29,29 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
return $table
->query(Mapper::query())
->columns([
MapperRightColumn::make('right')->label('BETSAPI'),
])
MapperRightColumn::make('right')->label(''),
])->searchable(['group', 'home', 'away'])
->defaultPaginationPageOption(5)
->filters([
// ...
])
->recordActions([
// ...
])
SelectFilter::make('group_cc')
->relationship('country_betsapi', 'name')
->searchable()
->preload()
->multiple()
->placeholder('Country')
->label('Countries'),
SelectFilter::make('group_id')
->options(fn () => Mapper::groupBy('group_id')->pluck('group', 'group_id'))
->columnSpan(2)
->searchable()
->preload()
->multiple()
->placeholder('League')
->label('Leagues'),
], layout: FiltersLayout::AboveContent)
->hiddenFilterIndicators()
->filtersFormColumns(3)
->deferFilters(false)
->toolbarActions([
]);
}
+1 -1
View File
@@ -36,7 +36,7 @@ class Event extends Model
public function country()
{
return $this->belongsTo(Country::class, 'country_id', 'tx_id');
return $this->belongsTo(Country::class, 'country_id', 'tx_id')->where('disabled', 0)->where('is_country', 1);
}
public function group()
@@ -18,6 +18,7 @@ return new class extends Migration
$table->boolean('disabled')->default(0);
$table->integer('multiline_setting_id')->default(1);
$table->integer('bookmaker_id')->default(0);
$table->integer('position')->default(0);
$table->integer('sort')->default(0);
$table->timestamps();
});
@@ -15,7 +15,8 @@ class RolesAndPermissionsSeeder extends Seeder
[
['name' => 'super_admin', 'guard_name' => 'web'],
['name' => 'konto_switch', 'guard_name' => 'web'],
['name' => 'betsapi_mapper', 'guard_name' => 'web'],
['name' => 'provider_menu', 'guard_name' => 'web'],
['name' => 'matchid_column', 'guard_name' => 'web'],
],
['name']
);
@@ -30,7 +31,8 @@ class RolesAndPermissionsSeeder extends Seeder
]);
$user->assignRole('super_admin');
$user->assignRole('konto_switch');
$user->assignRole('betsapi_mapper');
$user->assignRole('provider_menu');
$user->assignRole('matchid_column');
$user = User::factory()->create([
'name' => 'Ubaldo Perrucci',
@@ -43,6 +45,6 @@ class RolesAndPermissionsSeeder extends Seeder
]);
$user->assignRole('super_admin');
$user->assignRole('konto_switch');
$user->assignRole('betsapi_mapper');
$user->assignRole('provider_menu');
}
}
@@ -17,7 +17,18 @@
</x-slot>
<x-slot name="heading">
Event Mapper
<div class="flex justify-between items-center w-6xl">
<div>Event Mapper</div>
@if (auth()->user()->hasRole('provider_menu'))
<x-filament::input.wrapper>
<x-filament::input.select wire:model="status">
<option value="BetsApi">Provider BetsApi</option>
<option value="Magloo">Provider Magloo</option>
<option value="Logifutur">Provider Logifutur</option>
</x-filament::input.select>
</x-filament::input.wrapper>
@endif
</div>
</x-slot>
<div class="grid grid-cols-2 gap-4 drag-and-drop text-sm" x-data="{ event_id: 0, match_id: 0, overleftcolumn: false, overrightcolumn: false }">