wip
This commit is contained in:
1 parent
419148cd18
commit
7abcc5c56c
75 files changed
+32250
-127794
No files matched your search
@@ -3,11 +3,11 @@
|
||||
namespace App\Console\Commands\Grapper\TxOdds;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxCountry;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxElement;
|
||||
use App\Console\Commands\Grapper\TxOdds\Fixtures\TxLiga;
|
||||
use App\Console\Commands\NuhBash;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Element;
|
||||
use App\Models\Event;
|
||||
use App\Models\Group;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@@ -17,7 +17,6 @@ class Fixtures
|
||||
{
|
||||
$debug = NuhBash::$options['d'] ?? 0;
|
||||
$print = NuhBash::$options['p'] ?? 0;
|
||||
$read = NuhBash::$options['r'] ?? 0;
|
||||
$break = NuhBash::$options['b'] ?? 0;
|
||||
|
||||
$total = 0;
|
||||
@@ -29,38 +28,86 @@ class Fixtures
|
||||
$to = $date->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, $debug);
|
||||
$data = Curl::load($url);
|
||||
|
||||
if ($print) {
|
||||
Notice::note($data, '', 1);
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($data['match'] as $row) {
|
||||
$e = [];
|
||||
foreach ($data['match'] as $match) {
|
||||
|
||||
foreach ($match as $key => $v) {
|
||||
|
||||
switch ($key) {
|
||||
case '@attributes':
|
||||
$e['txodds_id'] = (int) $v['id'];
|
||||
break;
|
||||
|
||||
case 'time':
|
||||
$starttime = Carbon::createFromDate($v)->toDateTimeString();
|
||||
break;
|
||||
|
||||
case 'group':
|
||||
|
||||
$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]);
|
||||
|
||||
$count++;
|
||||
$txodds_id = array_column($row, 'id');
|
||||
$spid = array_column($row['group'], 'spid');
|
||||
$country_id = TxCountry::find($row['group']);
|
||||
$liga_id = TxLiga::find($country_id, $row['group']);
|
||||
$home_id = TxElement::find($row['hteam'], 1);
|
||||
$away_id = TxElement::find($row['ateam'], 1);
|
||||
|
||||
$event = Event::updateOrCreate([
|
||||
'starttime' => date('Y-m-d H:i:s', strtotime($row['time'])),
|
||||
'sport_id' => (int) $spid[0],
|
||||
'provider_id' => 1,
|
||||
'txodds_id' => (int) $txodds_id[0],
|
||||
'country_id' => (int) $country_id,
|
||||
'liga_id' => (int) $liga_id,
|
||||
'home_id' => (int) $home_id,
|
||||
'away_id' => (int) $away_id,
|
||||
]);
|
||||
}
|
||||
Notice::note("$from - $count events processed", 'g');
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("$from - $count events processed", 'g');
|
||||
}
|
||||
|
||||
$total += $count;
|
||||
|
||||
if ($break) {
|
||||
if ($break || $debug) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user