55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\Betsapi;
|
|
|
|
use App\Console\Commands\Curl;
|
|
use App\Console\Commands\Nuh;
|
|
use App\Models\Element;
|
|
use App\Models\ElementProvider;
|
|
use App\Utilities\Notice;
|
|
|
|
class ElementIcons
|
|
{
|
|
public static function grap()
|
|
{
|
|
$debug = Nuh::$options['d'] ?? 0;
|
|
|
|
$min_id = 1;
|
|
while ($min_id > 0) {
|
|
|
|
if ($min_id == 1) {
|
|
$url = 'https://api.b365api.com/v3/team?token='.config('env.betsapi_token').'&sport_id=1&is_esports=1';
|
|
} else {
|
|
$url = 'https://api.b365api.com/v3/team?token='.config('env.betsapi_token').'&sport_id=1&is_esports=1&max_id='.$min_id;
|
|
}
|
|
|
|
$data = Curl::load($url);
|
|
|
|
if (! $data['success']) {
|
|
break;
|
|
}
|
|
|
|
$min_id = $data['pager']['min_id'];
|
|
|
|
if ($debug) {
|
|
Notice::note("MinId: $min_id");
|
|
}
|
|
|
|
foreach ($data['results'] as $value) {
|
|
|
|
if (! isset($value['is_esports']) && $value['image_id'] > 0 && $value['cc'] != '') {
|
|
|
|
$res = ElementProvider::where('provider_id', 2)->where('provider_element_id', (int) $value['id'])->first();
|
|
|
|
if ($res) {
|
|
if ($debug) {
|
|
Notice::note($value, 'b');
|
|
}
|
|
Element::where('id', $res->element_id)->update(['betsapi_image_id' => $value['image_id']]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|