wip
This commit is contained in:
1 parent
7abcc5c56c
commit
90bba45c0a
26 files changed
+3448
-32353
No files matched your search
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\TxOdds;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\NuhBash;
|
||||
use App\Console\Commands\Xml;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Element;
|
||||
use App\Models\Event;
|
||||
@@ -19,86 +19,91 @@ class Fixtures
|
||||
$print = NuhBash::$options['p'] ?? 0;
|
||||
$break = NuhBash::$options['b'] ?? 0;
|
||||
|
||||
$count = 0;
|
||||
$total = 0;
|
||||
$date = Carbon::now();
|
||||
$now = Carbon::now();
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*/
|
||||
$info = Event::where('starttime', '<', $now->toDateTimeString())->delete();
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Deleted: $info");
|
||||
}
|
||||
/**
|
||||
* Grap
|
||||
*/
|
||||
for ($i = 0; $i < 30; $i++) {
|
||||
|
||||
$from = $date->addDays($i)->toDateString();
|
||||
$to = $date->addDays($i + 1)->toDateString();
|
||||
$from = $now->addDays($i)->toDateString();
|
||||
$to = $now->addDays($i + 1)->toDateString();
|
||||
|
||||
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.config('nuh.txodds_token_soccer')."&date=$from,$to&json=2";
|
||||
$data = Curl::load($url);
|
||||
$url = 'https://xml2.txodds.com/feed/result/xml.php?'.NuhBash::$AUTHTOKEN."&date=$from,$to";
|
||||
|
||||
$data = Xml::load($url);
|
||||
|
||||
if ($print) {
|
||||
Notice::note($data, '', 1);
|
||||
dd($data);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$e = [];
|
||||
foreach ($data['match'] as $match) {
|
||||
foreach ($data as $row) {
|
||||
// <match id="14563695" xsid="0" gsmid="0" last_updated="2025-12-02T08:31:11+00:00">
|
||||
// <time>2025-12-03T22:30:00+00:00</time>
|
||||
// <group id="173093" cgid="1255" spid="1" cnid="467" mgid="1002" cname="Reserve League">FBARG Reserve League-25</group>
|
||||
// <hteam id="187003" >Boca Juniors II</hteam>
|
||||
// <ateam id="185803" >Gimnasia LP II</ateam>
|
||||
// <results>
|
||||
// <status last_updated="2025-12-02T08:31:10+00:00" minute="-1">Sched</status>
|
||||
// <result id="1" name="CURRENT" value="" />
|
||||
// </results>
|
||||
// </match>
|
||||
$event = [];
|
||||
$event['txodds_id'] = (int) $row['id'];
|
||||
$event['starttime'] = Carbon::createFromDate((string) $row->time)->toDateTimeString();
|
||||
$group_name = (string) $row->group;
|
||||
$event['group_id'] = (int) $row->group['id'];
|
||||
$event['sport_id'] = (int) $row->group['spid'];
|
||||
$event['country_id'] = (int) $row->group['cnid'];
|
||||
$event['competition_group_id'] = (int) $row->group['cgid'];
|
||||
$competition_group_name = (string) $row->group['cname'];
|
||||
$home = (string) $row->hteam;
|
||||
$event['home_id'] = (int) $row->hteam['id'];
|
||||
$away = (string) $row->ateam;
|
||||
$event['away_id'] = (int) $row->ateam['id'];
|
||||
|
||||
foreach ($match as $key => $v) {
|
||||
Group::updateOrCreate([
|
||||
'txodds_id' => $event['group_id'],
|
||||
'competition_group_id' => $event['competition_group_id'],
|
||||
'sport_id' => $event['sport_id'],
|
||||
'country_id' => $event['country_id'],
|
||||
], [
|
||||
'name' => $group_name,
|
||||
]);
|
||||
|
||||
switch ($key) {
|
||||
case '@attributes':
|
||||
$e['txodds_id'] = (int) $v['id'];
|
||||
break;
|
||||
CompetitionGroup::updateOrCreate([
|
||||
'txodds_id' => $event['competition_group_id'],
|
||||
'sport_id' => $event['sport_id'],
|
||||
'country_id' => $event['country_id'],
|
||||
], [
|
||||
'name' => $competition_group_name,
|
||||
]);
|
||||
|
||||
case 'time':
|
||||
$starttime = Carbon::createFromDate($v)->toDateTimeString();
|
||||
break;
|
||||
Element::firstOrCreate([
|
||||
'txodds_id' => $event['home_id'],
|
||||
'name' => $home,
|
||||
'sport_id' => $event['sport_id'],
|
||||
]);
|
||||
|
||||
case 'group':
|
||||
Element::firstOrCreate([
|
||||
'txodds_id' => $event['away_id'],
|
||||
'name' => $away,
|
||||
'sport_id' => $event['sport_id'],
|
||||
]);
|
||||
|
||||
$e['sport_id'] = (int) $v['@attributes']['spid'];
|
||||
$e['country_id'] = (int) $v['@attributes']['cnid'];
|
||||
$e['group_id'] = (int) $v['@attributes']['id'];
|
||||
$e['competition_group_id'] = (int) $v['@attributes']['cgid'];
|
||||
|
||||
Group::firstOrCreate([
|
||||
'txodds_id' => $v['@attributes']['id'],
|
||||
'competition_group_id' => $e['competition_group_id'],
|
||||
], [
|
||||
'name' => (string) $v['@text'],
|
||||
'sport_id' => $e['sport_id'],
|
||||
'country_id' => $e['country_id'],
|
||||
]);
|
||||
|
||||
CompetitionGroup::firstOrCreate([
|
||||
'txodds_id' => $v['@attributes']['cgid'],
|
||||
'name' => $v['@attributes']['cname'],
|
||||
'sport_id' => $e['sport_id'],
|
||||
'country_id' => $e['country_id'],
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'hteam':
|
||||
$e['home_id'] = $v['@attributes']['id'];
|
||||
|
||||
Element::firstOrCreate([
|
||||
'txodds_id' => (int) $v['@attributes']['id'],
|
||||
'name' => $v['@text'],
|
||||
'sport_id' => $e['sport_id'],
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'ateam':
|
||||
$e['away_id'] = $v['@attributes']['id'];
|
||||
|
||||
Element::firstOrCreate([
|
||||
'txodds_id' => (int) $v['@attributes']['id'],
|
||||
'name' => $v['@text'],
|
||||
'sport_id' => $e['sport_id'],
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Event::firstOrCreate($e, ['starttime' => $starttime]);
|
||||
Event::updateOrCreate($event, ['starttime' => $event['starttime']]);
|
||||
|
||||
$count++;
|
||||
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
@@ -111,6 +116,8 @@ class Fixtures
|
||||
break;
|
||||
}
|
||||
}
|
||||
Notice::note("Total - $total events processed", 'g');
|
||||
if ($debug) {
|
||||
Notice::note("Total - $total events processed", 'g');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user