Files
nuhodds_fi4/app/Console/Commands/Grapper/TxOdds/Odds/Odds_2Way.php
T
2026-02-19 14:54:41 +01:00

38 lines
1011 B
PHP

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