mapper wip
This commit is contained in:
1 parent
ba6c2263e3
commit
02712ec610
27 files changed
+1070
-158
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Betsapi;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Fixtures
|
||||
{
|
||||
public static function grap()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$test = Nuh::$options['t'] ?? 0;
|
||||
$echo = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('bapi');
|
||||
|
||||
$total = 10;
|
||||
foreach ($sportmap as $sport_id => $betsapi_sport_id) {
|
||||
$page = 1;
|
||||
while ($page <= $total) {
|
||||
|
||||
$url = "https://api.b365api.com/v3/events/upcoming?sport_id=$betsapi_sport_id&page=$page&skip_esports=1&token=".config('env.betsapi_token');
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
$page++;
|
||||
|
||||
$total = round($data['pager']['total'] / $data['pager']['per_page']);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Page: $page \nTotal: $total");
|
||||
}
|
||||
|
||||
if (isset($data['results'])) {
|
||||
|
||||
foreach ($data['results'] as $row) {
|
||||
|
||||
$event = [
|
||||
'sport_id' => (int) $row['sport_id'],
|
||||
'provider_id' => (int) Nuh::$options['provider_id'],
|
||||
'starttime' => Carbon::createFromTimestamp((string) $row['time'])->toDateTimeString(),
|
||||
'home' => $row['home']['name'] ?? '',
|
||||
'home_id' => (int) $row['home']['id'],
|
||||
'home_cc' => $row['home']['cc'] ?? '',
|
||||
'away' => $row['away']['name'] ?? '',
|
||||
'away_id' => (int) $row['away']['id'],
|
||||
'away_cc' => $row['away']['cc'] ?? '',
|
||||
'group' => $row['league']['name'] ?? '',
|
||||
'group_id' => (int) $row['league']['id'] ?? 0,
|
||||
'group_cc' => $row['league']['cc'] ?? '',
|
||||
];
|
||||
|
||||
Mapper::updateOrCreate(['betsapi_id' => (int) $row['id']], $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('FIRST LOOP', 'g', 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user