Files
nuhodds_fi4/app/Console/Commands/Grapper/Betsapi/Willhill.php
T
2025-12-22 08:15:59 +01:00

50 lines
1.4 KiB
PHP

<?php
namespace App\Console\Commands\Grapper\Betsapi;
use App\Console\Commands\Curl;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Odds3way;
use App\Utilities\Notice;
class Willhill
{
public static function grap()
{
$debug = Nuh::$options['d'] ?? 0;
/**
* williamhill
*/
$bookmaker_id = 42;
$res = Odds3way::join('events', 'odds_3ways.event_id', 'events.id')
->where('odds_3ways.bookmaker_id', $bookmaker_id)
->where('events.betsapi_id', 0)
->where('odds_3ways.bmoid', '>', 0)->pluck('odds_3ways.event_id', 'odds_3ways.bmoid');
foreach ($res as $willhill_id => $txodds_id) {
$url = 'https://api.b365api.com/v1/williamhill/result?token='.config('env.betsapi_token').'&event_id='.$willhill_id;
$data = Curl::load($url);
$betsapi_id = $data['results'][0]['id'] ?? 0;
$bet365_id = $data['results'][0]['bet365_id'] ?? 0;
if ($debug) {
Notice::note(["TXdds ID : $txodds_id", "Betsapi ID : $betsapi_id", "Bet365 ID : $bet365_id", "Willhill ID : $willhill_id"], 'b');
}
if ($betsapi_id) {
Event::where('id', (int) $txodds_id)->update(['betsapi_id' => $betsapi_id, 'bet365_id' => $bet365_id]);
Mapper::where('event_id', $betsapi_id)->delete();
}
}
}
}