57 lines
2.0 KiB
PHP
57 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds;
|
|
|
|
use App\Console\Commands\Curl;
|
|
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxElement;
|
|
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxLigas;
|
|
use App\Console\Commands\NuhBash;
|
|
use App\Models\Event;
|
|
use App\Utilities\Notice;
|
|
|
|
class FixturesSoccer
|
|
{
|
|
public static function call()
|
|
{
|
|
$debug = NuhBash::$options['d'] ?? 0;
|
|
$print = NuhBash::$options['p'] ?? 0;
|
|
|
|
$total = 0;
|
|
for ($i = 0; $i < 30; $i++) {
|
|
$str1 = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + $i, date('Y')));
|
|
$str2 = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + 1 + $i, date('Y')));
|
|
|
|
$url = 'https://xml2.txodds.com/feed/result/xml.php?ident=betaid1&passwd='.config('nuh.txodds_token')."&date=$str1,$str2&json=2";
|
|
$data = Curl::load($url, $debug);
|
|
|
|
if ($print) {
|
|
Notice::note($data, '', 1);
|
|
}
|
|
|
|
$count = 0;
|
|
foreach ($data['match'] as $row) {
|
|
$count++;
|
|
$txodds_id = array_column($row, 'id');
|
|
$spid = array_column($row['group'], 'spid');
|
|
$liga_id = TxLigas::find($row['group']);
|
|
$home_id = TxElement::find($row['hteam'], 1);
|
|
$away_id = TxElement::find($row['ateam'], 1);
|
|
|
|
$event = Event::firstOrCreate([
|
|
'starttime' => date('Y-m-d H:i:s', strtotime($row['time'])),
|
|
'sport_id' => (int) $spid[0],
|
|
'provider_id' => 1,
|
|
'txodds_id' => (int) $txodds_id,
|
|
'liga_id' => $liga_id,
|
|
'home_id' => $home_id,
|
|
'away_id' => $away_id,
|
|
]);
|
|
// dd($event);
|
|
}
|
|
Notice::note("$str1 - $count events processed", 'g');
|
|
$total += $count;
|
|
}
|
|
Notice::note("Total - $total events processed", 'g');
|
|
}
|
|
}
|