Files
nuhodds_fi4/app/Console/Commands/Grapper/TxOdds/Events.php
T
2025-08-14 11:23:27 +02:00

52 lines
1.7 KiB
PHP

<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Grapper\Grapper;
use App\Models\Event;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
class Events
{
public static function grap()
{
Notice::note('txodd fixture sport: '.Grapper::$options['sport_id'], 'b');
$debug = Grapper::$options['d'] ?? 0;
$now = Carbon::tomorrow();
for ($i = 0; $i < 60; $i++) {
$from = $now->toDateString();
$to = $now->addDays(1)->toDateString();
$url = Grapper::$domain.'feed/result/xml.php?'.Grapper::$auth."&date=$from,$to";
if ($debug) {
Notice::note($url, 'y');
}
$xml = simplexml_load_file($url, null, LIBXML_NOCDATA);
foreach ($xml->match as $_match) {
Event::updateOrCreate([
'txid' => (int) $_match['id'],
'spid' => Grapper::$options['sport_id'],
'prid' => Grapper::$options['provider_id'],
'cnid' => (int) $_match->group['cnid'], // country_id
'grid' => (int) $_match->group['id'], // group_id
'cgid' => (int) $_match->group['cgid'], // competition_group_id
'hoid' => (int) $_match->hteam['id'],
'awid' => (int) $_match->ateam['id'],
'home' => (string) $_match->hteam,
'away' => (string) $_match->ateam,
'liga' => (string) $_match->group['cname'],
], [
'time' => Carbon::parse($_match->time)->toDateTimeString(),
]);
}
}
}
}