Files
nuhodds_fi4/app/Console/Commands/Grapper/TxOdds/Odds/Odds_Ggng.php
T
2026-10-04 15:25:03 +02:00

39 lines
1004 B
PHP

<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsGgng;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class Odds_Ggng
{
public static function grap($odds, $offer)
{
$block_update = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['gg'] = (float) $value->o1;
$odds['ng'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['gg'], $odds['ng']], 1);
$res = OddsGgng::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsGgng::create($odds);
} elseif (! $block_update) {
$res->gg = $odds['gg'];
$res->ng = $odds['ng'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}