This commit is contained in:
salam committed 2026-01-01 13:32:19 +01:00
1 parent a26c555b05
commit cec5a5e2f7
20 files changed
+211 -120

No files matched your search

-43
View File
@@ -1,43 +0,0 @@
<?php
namespace App\Actions;
use App\Models\Event;
class MapperEvents
{
public static function load()
{
switch (auth()->user()->provider_id) {
case 2:
// BETSAPI
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('betsapi_id', 0);
break;
case 20:
// Magloo Kenia
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('magnig_id', 0);
break;
case 24:
// Magloo Nigeria
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('magken_id', 0);
break;
case 26:
// Logifuture Nigeria
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('lognig_id', 0);
break;
case 27:
// Magloo Colombia
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('logcol_id', 0);
break;
default:
return Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0);
break;
}
}
}
-14
View File
@@ -1,14 +0,0 @@
<?php
namespace App\Actions;
use App\Models\Mapper;
class MapperProvider
{
public static function load()
{
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id);
}
}
@@ -4,8 +4,7 @@ namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Mapper\FindEvent;
use App\Models\Sport;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
@@ -59,6 +58,7 @@ class Fixtures
if (isset($row['home']['id']) && isset($row['away']['id']) && strpos($row['league']['name'], 'Esoccer') === false) {
$event = [
'event_id' => (int) $row['id'],
'sport_id' => (int) $sport_id,
'provider_id' => (int) Nuh::$options['provider_id'],
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
@@ -72,13 +72,8 @@ class Fixtures
'group_id' => (int) $row['league']['id'] ?? 0,
'group_cc' => strtoupper($row['league']['cc']) ?? '',
];
$event_id = (int) $row['id'];
$match_id = Event::where('betsapi_id', $event_id)->value('id');
if ($match_id) {
Mapper::where('event_id', $event_id)->delete();
} else {
Mapper::updateOrCreate(['event_id' => $event_id], $event);
}
FindEvent::search($event);
}
}
}
@@ -0,0 +1 @@
{"success":1,"pager":{"page":1,"per_page":50,"total":103},"results":[{"id":"11196131","sport_id":"1","time":"1767265200","time_status":"0","league":{"id":"2369","name":"Syria Division 1","cc":"sy"},"home":{"id":"1232083","name":"Omaya SC","image_id":"1311226","cc":"sy"},"away":{"id":"184357","name":"Hutteen","image_id":"189388","cc":"sy"},"ss":null,"round":"3"},{"id":"11196132","sport_id":"1","time":"1767265200","time_status":"0","league":{"id":"2369","name":"Syria Division 1","cc":"sy"},"home":{"id":"177711","name":"Tishreen","image_id":"157792","cc":"sy"},"away":{"id":"1231539","name":"Khan Shaykhun SC","image_id":"1311228","cc":"sy"},"ss":null,"round":"3"},{"id":"11198690","sport_id":"1","time":"1767265200","time_status":"0","league":{"id":"42027","name":"Algeria U20 League","cc":"dz"},"home":{"id":"1194258","name":"ES Ben Aknoun U20","image_id":"1292973","cc":"dz"},"away":{"id":"1206680","name":"Paradou AC U20","image_id":"1300782","cc":"dz"},"ss":null,"bet365_id":"187231851"},{"id":"10173612","sport_id":"1","time":"1767270600","time_status":"0","league":{"id":"880","name":"England Championship","cc":"gb"},"home":{"id":"17201","name":"Blackburn","image_id":"46","cc":"gb"},"away":{"id":"1875","name":"Wrexham","image_id":"64","cc":"gb"},"ss":null,"round":"25","bet365_id":"186496893"},{"id":"10270360","sport_id":"1","time":"1767270600","time_status":"0","league":{"id":"156","name":"Wales Premier League","cc":"gb"},"home":{"id":"60899","name":"Colwyn Bay","image_id":"597088","cc":"gb"},"away":{"id":"8512","name":"Flint Town Utd","image_id":"37090","cc":"gb"},"ss":null,"round":"21","bet365_id":"185889723"},{"id":"10476839","sport_id":"1","time":"1767270900","time_status":"0","league":{"id":"809","name":"Saudi Arabia Division 1","cc":"sa"},"home":{"id":"56220","name":"Al Orubah","image_id":"114259","cc":"sa"},"away":{"id":"682282","name":"Al Jandal","image_id":"522144","cc":"sa"},"ss":null,"round":"14","bet365_id":"185936511"},{"id":"10476859","sport_id":"1","time":"1767270900","time_status":"0","league":{"id":"809","name":"Saudi Arabia Division 1","cc":"sa"},"home":{"id":"56221","name":"Al Taee","image_id":"168072","cc":"sa"},"away":{"id":"583338","name":"Al Zulfi","image_id":"757980","cc":"sa"},"ss":null,"round":"14","bet365_id":"185936514"},{"id":"11133547","sport_id":"1","time":"1767271800","time_status":"0","league":{"id":"1945","name":"Saudi Arabia Division 2","cc":"sa"},"home":{"id":"244281","name":"Weg Taif SC","image_id":"276755","cc":"sa"},"away":{"id":"622080","name":"Al Rayyan Ar Rawdah","image_id":"857289","cc":"sa"},"ss":null,"round":"13"},{"id":"10321213","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"319","name":"England Northern Premier League","cc":"gb"},"home":{"id":"46501","name":"Morpeth Town","image_id":"47120","cc":"gb"},"away":{"id":"193388","name":"Stockton Town","image_id":"630010","cc":"gb"},"ss":null,"round":"25","bet365_id":"186823577"},{"id":"10874159","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"854","name":"Iran Pro League","cc":"ir"},"home":{"id":"15854","name":"Sepahan","image_id":"8018","cc":"ir"},"away":{"id":"43979","name":"Esteghlal","image_id":"34316","cc":"ir"},"ss":"3-0","round":"10"},{"id":"11173754","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"39521","name":"Iraq Stars League","cc":"iq"},"home":{"id":"284537","name":"Al Minaa","image_id":"405353","cc":"iq"},"away":{"id":"594899","name":"Newroz SC","image_id":"845058","cc":"iq"},"ss":null,"round":"9","bet365_id":"187165073"},{"id":"11173872","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"39521","name":"Iraq Stars League","cc":"iq"},"home":{"id":"284412","name":"Al Najaf","image_id":"508998","cc":"iq"},"away":{"id":"239046","name":"Al Naft SC","image_id":"508988","cc":"iq"},"ss":null,"round":"9","bet365_id":"187149701"},{"id":"11202124","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"1212","name":"England Northern League Division One","cc":"gb"},"home":{"id":"172842","name":"Grimsby Borough","image_id":"58005","cc":"gb"},"away":{"id":"507428","name":"North Ferriby","image_id":"170","cc":"gb"},"ss":null,"bet365_id":"187149512"},{"id":"11202354","sport_id":"1","time":"1767272400","time_status":"0","league":{"id":"1212","name":"England Northern League Division One","cc":"gb"},"home":{"id":"64562","name":"Bedworth Utd","image_id":"188","cc":"gb"},"away":{"id":"296243","name":"Coventry Sphinx","image_id":"37994","cc":"gb"},"ss":null,"bet365_id":"187149503"},{"id":"11205156","sport_id":"1","time":"1767273600","time_status":"0","league":{"id":"12352","name":"Oman U21 Championship","cc":"om"},"home":{"id":"241665","name":"Dhofar U21","image_id":null,"cc":null},"away":{"id":"1231918","name":"Al Shabab Seeb U21","image_id":null,"cc":null},"ss":null,"bet365_id":"187161283"},{"id":"10205757","sport_id":"1","time":"1767276000","time_status":"0","league":{"id":"18163","name":"Wales Championship North","cc":"gb"},"home":{Line truncated
@@ -13,7 +13,7 @@ use App\Models\BettypeUser;
use App\Models\Country;
use App\Models\Event;
use App\Models\MultilineClient;
use Carbon\Carbon;
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
@@ -28,6 +28,7 @@ use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
class EventsTable
{
@@ -235,13 +236,30 @@ 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);
return $arr;
})
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(2)
->startPrefix('From')
->displayFormat('d M Y')
->minDate(now())
->hiddenLabel()
->label('')
->live(),
Action::make('reset')
->hiddenLabel()
->color('gray')
->icon('heroicon-o-arrow-path')
->action(function ($livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$livewire->tableSearch = ''; // Clears the main search bar
}),
])
->query(function (Builder $query, array $data): Builder {
return $query
@@ -251,6 +269,28 @@ class EventsTable
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
)->when(
$data['starttime_period'],
function (Builder $query, $starttime_period) {
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
$from = Carbon::createFromDate($starttime_period['start']);
$end = Carbon::createFromDate($starttime_period['end']);
return $query
->where('starttime', '>=', $from->format('Y-m-d 00:00:00'))
->where('starttime', '<=', $end->format('Y-m-d 00:00:00'));
} elseif (isset($starttime_period['start'])) {
$from = Carbon::createFromDate($starttime_period['start']);
return $query
->where('starttime', '>=', $from->format('Y-m-d 00:00:00'));
} elseif (isset($starttime_period['end'])) {
$end = Carbon::createFromDate($starttime_period['end']);
return $query
->where('starttime', '<=', $end->format('Y-m-d 00:00:00'));
}
}
);
})
->columns(6)->columnSpan(6),
+4 -4
View File
@@ -2,8 +2,8 @@
namespace App\Livewire;
use App\Actions\MapperEvents;
use App\Filament\Tables\Columns\MapperLeftColumn;
use App\Mapper\LoadEvents;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
@@ -38,7 +38,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
return $table
->query(MapperEvents::load())
->query(LoadEvents::load())
->columns([
MapperLeftColumn::make('left')->label(''),
])
@@ -108,6 +108,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->columns(4)->columnSpan(4),
], layout: FiltersLayout::AboveContent)
->filtersFormColumns(3)
->persistFiltersInSession()
->deferFilters(false)
->toolbarActions([
Action::make('reload_data_left')
@@ -117,8 +118,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
// ->icon('phosphor-x')
->action(function (Component $livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$livewire->tableSearch = ''; // Clears the main search bar
$this->dispatch('reload_data');
$this->tableSearch = ''; // Clears the main search bar
}),
]);
}
+4 -4
View File
@@ -2,8 +2,8 @@
namespace App\Livewire;
use App\Actions\MapperProvider;
use App\Filament\Tables\Columns\MapperRightColumn;
use App\Mapper\LoadProvider;
use App\Models\Event;
use App\Models\Mapper;
use Filament\Actions\Action;
@@ -34,7 +34,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
return $table
->query(MapperProvider::load())
->query(LoadProvider::load())
->columns([
MapperRightColumn::make('right')->label(''),
])->searchable(['home', 'away'])
@@ -81,6 +81,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->columns(4)->columnSpan(4),
], layout: FiltersLayout::AboveContent)
// ->hiddenFilterIndicators()
->persistFiltersInSession()
->filtersFormColumns(3)
->deferFilters(false)
->toolbarActions([
@@ -91,8 +92,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
// ->icon('phosphor-x')
->action(function (Component $livewire) {
$livewire->resetTableFiltersForm(); // Clears all filters
$livewire->tableSearch = ''; // Clears the main search bar
$this->dispatch('reload_data');
$this->tableSearch = ''; // Clears the main search bar
}),
]);
}
+1 -1
View File
@@ -62,7 +62,7 @@ class TopMenuItems extends Component
$bookmaker_id = array_shift($bookmakers);
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
User::where('id', auth()->user()->id)->update(['sport_id' => 1, 'provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'client_id' => $client_id]);
$this->js('window.location.reload()');
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Mapper;
use App\Models\Event;
use App\Models\Mapper;
use Illuminate\Support\Facades\Auth;
class FindEvent
{
public static function search($event)
{
dd($event);
$event_id = $event['event_id'];
$match_id = Event::where('betsapi_id', $event_id)->value('id');
if ($match_id) {
Mapper::where('event_id', $event_id)->delete();
} else {
Mapper::updateOrCreate(['event_id' => $event_id], $event);
}
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id);
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Mapper;
use App\Models\Event;
use Illuminate\Support\Facades\Auth;
class LoadEvents
{
public static function load()
{
switch (Auth::user()->provider_id) {
case 2:
// BETSAPI
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('betsapi_id', 0);
break;
case 20:
// Magloo Kenia
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('magnig_id', 0);
break;
case 24:
// Magloo Nigeria
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('magken_id', 0);
break;
case 26:
// Logifuture Nigeria
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('lognig_id', 0);
break;
case 27:
// Magloo Colombia
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('logcol_id', 0);
break;
default:
return Event::query()->where('sport_id', Auth::user()->sport_id)->where('betradar_id', 0);
break;
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace App\Mapper;
use App\Models\Mapper;
use Illuminate\Support\Facades\Auth;
class LoadProvider
{
public static function load()
{
return Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id);
}
}