wip matches

This commit is contained in:
salam committed 2025-08-27 12:51:03 +02:00
1 parent adb15e701b
commit 7116d3c576
33 files changed
+379 -176

No files matched your search

-36
View File
@@ -1,36 +0,0 @@
<?php
namespace App\Console\Commands\Grapper;
use App\Utilities\Notice;
class Helper
{
/**
* Create a new class instance.
*/
public static function get_auth_string()
{
if (Grapper::$options['provider_id'] == 1) {
// txodds soccer
Grapper::$auth = 'ident=betaid1&passwd=Dy59vpRC';
Grapper::$domain = 'https://xml2.txodds.com/';
} elseif (Grapper::$options['provider_id'] == 3) {
// txodds others
Grapper::$auth = 'ident=betaid2&passwd=Dy59vpRC';
Grapper::$domain = 'https://xml2.txodds.com/';
} else {
Notice::note('error txodds provider', 'r', 1);
}
}
public static function margin($arr)
{
$r = 0;
foreach ($arr as $key => $value) {
$r += 100 / $value;
}
return round($r, 3);
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Models\Element;
class TxElement
{
public static function find($element, $sport_id)
{
// dd($element);
$txodds_id = array_column($element, 'id');
$element = Element::firstOrCreate([
'name' => (string) $element['@text'],
'sport_id' => $sport_id,
'txodds_id' => (int) $txodds_id[0],
]);
return $element->id;
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\NuhBash;
use App\Models\Country;
use App\Models\Liga;
class TxLigas
{
public static function find($group)
{
$debug = NuhBash::$options['debug'] ?? 0;
$cgid = array_column($group, 'cgid');
$cnid = array_column($group, 'cnid');
$spid = array_column($group, 'spid');
$cname = array_column($group, 'cname');
$country_id = Country::where('txid', $cnid)->value('id');
$liga = Liga::firstOrCreate([
'name' => (string) $cname[0],
'sport_id' => (int) $spid[0],
'country_id' => $country_id,
'txodds_id' => (int) $cgid[0],
]);
return $liga->id;
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
use App\Console\Commands\Curl;
use App\Console\Commands\NuhBash;
use App\Models\Event;
class FixturesSoccer
{
public static function call()
{
$debug = NuhBash::$options['debug'] ?? 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);
foreach ($data['match'] as $row) {
$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);
}
}
}
}
@@ -1,34 +1,32 @@
<?php
namespace App\Console\Commands\Grapper\TxOdds;
namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\Grapper;
use App\Console\Commands\Grapper\TxOdds\FixturesSoccer;
use App\Console\Commands\NuhBash;
class TxOdds
class TxSwitch
{
/**
* https://docs.guzzlephp.org/en/latest/
*/
public static function switch()
{
switch (Grapper::$options['option_id']) {
switch (NuhBash::$options['id']) {
case 1:
// Leages
FixturesSoccer::call();
break;
case 2:
Events::grap();
break;
case 3:
// Flags
break;
case 4:
Odds::grap();
break;
case 5:
Countries::grap();
break;
default:
Note::notice('Provider not defined', 'r', 1);
Note::notice('wrong process id for txodds', 'r', 1);
break;
}
}