Files
nuhodds_fi4/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php
T

34 lines
887 B
PHP

<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\OddsTq;
use App\Utilities\Margin;
class _Tq
{
public static function grap($odds, $offer)
{
$block_create = Nuh::$options['b'] ?? 0;
foreach ($offer as $value) {
$odds['htq'] = (float) $value->o1;
$odds['atq'] = (float) $value->o3;
}
$odds['margin'] = (float) Margin::calculate([$odds['htq'], $odds['atq']], 1);
$res = OddsTq::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($odds);
} elseif (! $block_create) {
$res->htq = $odds['htq'];
$res->atq = $odds['atq'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
}
}
}