fixtures new wip

This commit is contained in:
salam committed 2026-01-16 07:42:33 +01:00
1 parent a1057d55a7
commit 69619802ce
27 files changed
+156 -187

No files matched your search

@@ -3,10 +3,8 @@
namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\FindFixture;
use App\Console\Commands\Grapper\Fixtures\FindFixture;
use App\Console\Commands\Nuh;
use App\Mapper\LoadElements;
use App\Mapper\LoadGroups;
use App\Models\Country;
use App\Models\Mapper;
use App\Models\Sport;
@@ -15,16 +13,14 @@ use Illuminate\Support\Carbon;
class Fixtures
{
public static $elements = [];
public static $groups = [];
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$today = Nuh::$options['t'] ?? 0;
FindFixture::start();
/**
* Delete Started
*/
@@ -34,10 +30,6 @@ class Fixtures
Notice::note("Deleted: $info");
}
self::$elements = LoadElements::load(Nuh::$options['provider_id']);
self::$groups = LoadGroups::load(Nuh::$options['provider_id']);
$country_map = Country::pluck('id', 'iso2');
$sportmap = Sport::map('bapi', 0, [1]);
@@ -100,7 +92,7 @@ class Fixtures
'group_cc' => strtoupper($row['league']['cc']) ?? '',
];
FindFixture::search($event, self::$groups[$sport_id], self::$elements[$sport_id]);
FindFixture::find($event);
}
}
}
@@ -1,9 +1,8 @@
<?php
namespace App\Console\Commands\Grapper;
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\CompetitionGroupProvider;
use App\Models\ElementProvider;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use Illuminate\Support\Carbon;
@@ -14,10 +13,15 @@ class FindFixture
public static $groups = [];
public static function search(&$event)
public static function start()
{
$match_id = false;
self::$elements = LoadElements::load(Nuh::$options['provider_id'], true);
self::$groups = LoadGroups::load(Nuh::$options['provider_id'], true);
}
public static function find(&$event)
{
$event_id = $event['event_id'];
$betradar_id = $event['betradar_id'] ?? 0;
@@ -34,151 +38,82 @@ class FindFixture
* USE ID
*************************************************/
dd($event);
// DEFAULT BETRADAR
if ($betradar_id) {
$match_id = Event::where('betradar_id', $betradar_id)->value('id');
$match = Event::where('betradar_id', $betradar_id)->first();
} else {
switch ($event['provider_id']) {
case 2:
// BETSAPI
$match_id = Event::where('betsapi_id', '=', $event_id)->value('id');
$match = Event::where('betsapi_id', '=', $event_id)->first();
break;
case 3:
// MAGLOO KENIA
$match_id = Event::where('magken_id', $event_id)->value('id');
$match = Event::where('magken_id', $event_id)->first();
break;
case 4:
// MAGLOO NIGERIA
$match_id = Event::where('magnig_id', $event_id)->value('id');
$match = Event::where('magnig_id', $event_id)->first();
break;
case 5:
// LOGIFUTUR NIGERA
$match_id = Event::where('lognig_id', $event_id)->value('id');
$match = Event::where('lognig_id', $event_id)->first();
break;
case 6:
// LOGIFUTUR COLOMBIA
$match_id = Event::where('logcol_id', $event_id)->value('id');
$match = Event::where('logcol_id', $event_id)->first();
break;
}
}
if ($match_id) {
if ($match) {
$update_array = [];
if ($betradar_id && ! $match->betradar_id) {
$update_array['betradar_id'] = $betradar_id;
}
if ($betsapi_id && ! $match->betsapi_id) {
$update_array['betsapi_id'] = $betsapi_id;
}
if ($bet365_id && ! $match->bet365_id) {
$update_array['bet365_id'] = $bet365_id;
}
if ($_1xbet_id && ! $match->_1xbet_id) {
$update_array['bet365_id'] = $_1xbet_id;
}
if ($bwin_id && ! $match->bwin_id) {
$update_array['bwin_id'] = $bwin_id;
}
if ($update_array) {
Event::where('id', $match->id)->update($update_array);
}
StoreData::store($event, $match);
Mapper::where('event_id', $event_id)->delete();
$event['id'] = $match_id;
$event['id'] = $match->id;
return;
}
/*************************************************
* USE DB
* FIND
*************************************************/
$home_id = $elements[$event['home_id']] ?? 0;
$away_id = $elements[$event['away_id']] ?? 0;
$competition_group_id = $groups[$event['group_id']] ?? 0;
if (! $home_id) {
$ele = [];
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = $event['provider_id'];
$ele['element_id'] = $match->home_id ?? 0;
$ele['name'] = $event['home'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['home_id']], $ele);
}
if (! $away_id) {
$ele = [];
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = $event['provider_id'];
$ele['element_id'] = $match->away_id ?? 0;
$ele['name'] = $event['away'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['away_id']], $ele);
}
if (! $competition_group_id) {
$group = [];
$group['sport_id'] = $event['sport_id'];
$group['provider_id'] = $event['provider_id'];
$group['competition_group_id'] = $match->competition_group_id;
$group['name'] = $event['group'];
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $event['group_id']], $group);
}
$update_array = [];
if ($betradar_id && ! $match->betradar_id) {
$update_array['betradar_id'] = $betradar_id;
}
if ($betsapi_id && ! $match->betsapi_id) {
$update_array['betsapi_id'] = $betsapi_id;
}
if ($bet365_id && ! $match->bet365_id) {
$update_array['bet365_id'] = $bet365_id;
}
if ($_1xbet_id && ! $match->_1xbet_id) {
$update_array['bet365_id'] = $_1xbet_id;
}
if ($bwin_id && ! $match->bwin_id) {
$update_array['bwin_id'] = $bwin_id;
}
// event_id
switch ($event['provider_id']) {
case 3:
// MAGLOO KENIA
if (! $match->magken_id) {
$update_array['magken_id'] = $event_id;
}
break;
case 4:
// MAGLOO NIGERIA
if (! $match->magnig_id) {
$update_array['magnig_id'] = $event_id;
}
break;
case 5:
// LOGIFUTUR NIGERA
if (! $match->lognig_id) {
$update_array['lognig_id'] = $event_id;
}
break;
case 6:
// LOGIFUTUR COLOMBIA
if (! $match->logcol_id) {
$update_array['logcol_id'] = $event_id;
}
break;
}
if ($update_array) {
Event::where('id', $match_id)->update($update_array);
}
$startime = $event['starttime'];
$from = Carbon::createFromDate($startime)->subDay();
$to = Carbon::createFromDate($startime)->addDay();
if ($find_by_name) {
$home_id = ElementProvider::where(['sport_id' => (int) $event['sport_id']])
->where('provider_id', $event['provider_id'])
->where('name', $home)
->value('element_id');
$away_id = ElementProvider::where(['sport_id' => (int) $event['sport_id']])
->where('provider_id', $event['provider_id'])
->where('name', $away)
->value('element_id');
$competition_group_id = CompetitionGroupProvider::where(['sport_id' => (int) $event['sport_id']])
->where('provider_id', $event['provider_id'])
->where('name', $groupname)
->value('competition_group_id');
}
$home_id = FindFixture::$elements[$event['home_id']] ?? 0;
$away_id = FindFixture::$elements[$event['away_id']] ?? 0;
$competition_group_id = FindFixture::$groups[$event['group_id']] ?? 0;
if ($home_id && $away_id && $competition_group_id) {
@@ -204,33 +139,34 @@ class FindFixture
$update_array['bet365_id'] = $bet365_id;
}
switch ($event['provider_id']) {
case 2:
// BETSAPI
$update_array['betsapi_id'] = $event_id;
break;
case 3:
// MAGLOO KENIA
$update_array['magken_id'] = $event_id;
break;
case 4:
// MAGLOO NIGERIA
$update_array['magnig_id'] = $event_id;
break;
case 5:
// LOGIFUTUR NIGERA
$update_array['lognig_id'] = $event_id;
break;
case 6:
// LOGIFUTUR COLOMBIA
$update_array['logcol_id'] = $event_id;
break;
default:
}
if ($update_array) {
Event::where('id', $match_id)->update($update_array);
}
switch ($event['provider_id']) {
case 2:
// BETSAPI
Event::where('id', $match_id)->update(['betsapi_id' => $event_id]);
break;
case 3:
// MAGLOO KENIA
Event::where('id', $match_id)->update(['magken_id' => $event_id]);
break;
case 4:
// MAGLOO NIGERIA
Event::where('id', $match_id)->update(['magnig_id' => $event_id]);
break;
case 5:
// LOGIFUTUR NIGERA
Event::where('id', $match_id)->update(['lognig_id' => $event_id]);
break;
case 6:
// LOGIFUTUR COLOMBIA
Event::where('id', $match_id)->update(['logcol_id' => $event_id]);
break;
default:
}
} else {
Mapper::updateOrCreate(['event_id' => $event_id], $event);
}
@@ -238,6 +174,5 @@ class FindFixture
Mapper::updateOrCreate(['event_id' => $event_id], $event);
}
$event['id'] = $match_id;
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\ElementProvider;
class LoadElements
{
public static function load($provider_id, $load_by_name = false)
{
$res = ElementProvider::where('provider_id', $provider_id)->get();
$r = [];
foreach ($res as $val) {
if ($load_by_name) {
$r[$val->sport_id][$val->name] = $val->element_id;
} else {
$r[$val->sport_id][$val->provider_element_id] = $val->element_id;
}
}
return $r;
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\CompetitionGroupProvider;
class LoadGroups
{
public static function load($provider_id, $load_by_name = false)
{
$res = CompetitionGroupProvider::where('provider_id', $provider_id)->get();
$r = [];
foreach ($res as $val) {
if ($load_by_name) {
$r[$val->sport_id][$val->name] = $val->competition_group_id;
} else {
$r[$val->sport_id][$val->provider_group_id] = $val->competition_group_id;
}
}
return $r;
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\CompetitionGroupProvider;
use App\Models\ElementProvider;
class StoreData
{
public static function store(&$event, &$match)
{
$home_id = FindFixture::$elements[$event['home_id']] ?? 0;
$away_id = FindFixture::$elements[$event['away_id']] ?? 0;
$competition_group_id = FindFixture::$groups[$event['group_id']] ?? 0;
if (! $home_id) {
$ele = [];
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = $event['provider_id'];
$ele['element_id'] = $match->home_id ?? 0;
$ele['name'] = $event['home'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['home_id']], $ele);
}
if (! $away_id) {
$ele = [];
$ele['sport_id'] = $event['sport_id'];
$ele['provider_id'] = $event['provider_id'];
$ele['element_id'] = $match->away_id ?? 0;
$ele['name'] = $event['away'];
ElementProvider::updateOrCreate(['provider_element_id' => (int) $event['away_id']], $ele);
}
if (! $competition_group_id) {
$group = [];
$group['sport_id'] = $event['sport_id'];
$group['provider_id'] = $event['provider_id'];
$group['competition_group_id'] = $match->competition_group_id;
$group['name'] = $event['group'];
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $event['group_id']], $group);
}
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\ElementProvider;
class StoreElement
{
public static function store(&$elements, $ele)
{
$provider_element_id = $ele['provider_element_id'] ?? 0;
unset($ele['provider_element_id']);
$sport_id = $ele['sport_id'] ?? 0;
if (! isset($elements[$sport_id][$provider_element_id])) {
ElementProvider::updateOrCreate(['provider_element_id' => (int) $provider_element_id], $ele);
}
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Console\Commands\Grapper\Fixtures;
use App\Models\CompetitionGroupProvider;
class StoreGroup
{
public static function store(&$groups, $group)
{
$provider_group_id = $group['provider_group_id'] ?? 0;
unset($group['provider_group_id']);
$sport_id = $group['sport_id'] ?? 0;
if (! isset($groups[$sport_id][$provider_group_id])) {
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $provider_group_id], $group);
}
}
}
+5 -9
View File
@@ -2,16 +2,14 @@
namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\Logifuture\Authentication;
use App\Console\Commands\Grapper\Logifuture\Basketball;
use App\Console\Commands\Grapper\Logifuture\Icehockey;
use App\Console\Commands\Grapper\Logifuture\LogifutureData;
use App\Console\Commands\Grapper\Logifuture\MapEvent;
use App\Console\Commands\Grapper\Logifuture\Soccer;
use App\Console\Commands\Grapper\Logifuture\Tennis;
use App\Console\Commands\Grapper\Logifuture\Tools\Authentication;
use App\Console\Commands\Grapper\Logifuture\Tools\LogifutureData;
use App\Console\Commands\Grapper\Logifuture\Tools\MapEvent;
use App\Console\Commands\Nuh;
use App\Mapper\LoadElements;
use App\Mapper\LoadGroups;
use App\Models\EventBookmaker;
use App\Models\Sport;
use App\Utilities\Notice;
@@ -37,9 +35,7 @@ class Logifuture
break;
}
FindFixture::$_elements = LoadElements::load(Nuh::$options['provider_id'], true);
FindFixture::$_groups = LoadGroups::load(Nuh::$options['provider_id'], true);
FindFixture::start();
$sportmap = Sport::map('logi', 1, [1, 2, 3, 5]);
@@ -63,7 +59,7 @@ class Logifuture
$event = MapEvent::filter($sport_id, $match);
FindFixture::search($event);
FindFixture::find($event);
if ($event['id']) {
@@ -1,6 +1,8 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture;
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Grapper\Logifuture\PrinzipalHandicap;
class Basketball
{
@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture;
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Nuh;
@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture;
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Nuh;
@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture;
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Nuh;
use Illuminate\Support\Carbon;
@@ -3,7 +3,7 @@
namespace App\Console\Commands\Grapper\Magloo;
use App\Console\Commands\Curl;
use App\Console\Commands\Grapper\FindFixture;
use App\Console\Commands\Grapper\Fixtures\FindFixture;
use App\Console\Commands\Grapper\Magloo\Odds\BaseUrl;
use App\Console\Commands\Nuh;
use App\Mapper\LoadElements;
@@ -14,15 +14,14 @@ use Illuminate\Support\Carbon;
class Fixtures
{
public static $elements = [];
public static $groups = [];
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
$proxy = Nuh::$options['p'] ?? 0;
FindFixture::start();
$sportmap = Sport::map('magl', 1, [1, 3]);
self::$elements = LoadElements::load(Nuh::$options['provider_id']);
@@ -101,7 +100,7 @@ class Fixtures
$event['away_id'] = $magloo['atId'];
$event['away'] = addslashes($teams[1]);
FindFixture::search($event, self::$groups[$sport_id], self::$elements[$sport_id]);
FindFixture::find($event);
}
}
}
@@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands\Grapper\Helper;
namespace App\Console\Commands\Grapper\TxOdds\Tools;
use App\Console\Commands\Nuh;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
@@ -2,7 +2,7 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\Helper\ActiveSpread;
use App\Console\Commands\Grapper\TxOdds\Tools\ActiveSpread;
use App\Console\Commands\Nuh;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;