71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds;
|
|
|
|
use App\Console\Commands\Nuh;
|
|
use App\Console\Commands\Xml;
|
|
use App\Models\Group;
|
|
use App\Models\MajorGroup;
|
|
use App\Models\Sport;
|
|
use App\Utilities\Notice;
|
|
|
|
class Groups
|
|
{
|
|
public static function grap()
|
|
{
|
|
$debug = Nuh::$options['d'] ?? 0;
|
|
|
|
$kontos = ['soccer' => config('env.txodds_betaid1'), 'other' => config('env.txodds_betaid2')];
|
|
|
|
$sport_map = Sport::getActiveSports();
|
|
|
|
Group::whereNotIn('sport_id', $sport_map)->delete();
|
|
|
|
$years = [date('y'), date('y') + 1];
|
|
|
|
foreach ($kontos as $konto => $authentication) {
|
|
|
|
$url = 'https://xml2.txodds.com/feed/groups.php?'.$authentication.'&sid='.implode(',', $years);
|
|
|
|
// <group>
|
|
// <id>181996</id>
|
|
// <mgroup id="1002">FBARG</mgroup>
|
|
// <name>Supercopa Entre Rios</name>
|
|
// <sid>26</sid>
|
|
// <fullname>FBARG Supercopa Entre Rios-26</fullname>
|
|
// <date1>2025-12-13 00:00:00</date1>
|
|
// <date2>2026-04-30 00:00:00</date2>
|
|
// </group>
|
|
|
|
$data = Xml::load($url);
|
|
|
|
$count = 0;
|
|
foreach ($data as $row) {
|
|
|
|
$mgroup = $row->mgroup;
|
|
|
|
$sport_id = MajorGroup::where('name', $mgroup)->value('sport_id');
|
|
|
|
if (in_array($sport_id, $sport_map)) {
|
|
|
|
Group::updateOrCreate(
|
|
['id' => (int) $row->id],
|
|
[
|
|
'name' => (string) $row->name,
|
|
'fullname' => (string) $row->fullname,
|
|
'mgroup' => (string) $row->mgroup,
|
|
'sid' => (int) $row->sid,
|
|
'sport_id' => (int) $sport_id,
|
|
'date1' => (string) $row->date1,
|
|
'date2' => (string) $row->date2,
|
|
]
|
|
);
|
|
$count++;
|
|
}
|
|
}
|
|
|
|
Notice::note("$count groups $konto processed", 'g');
|
|
}
|
|
}
|
|
}
|