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

37 lines
972 B
PHP

<?php
namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTq;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTq
{
public static function store($value, $base)
{
$odds = [];
$odds['htq'] = number_format($value['static'][4], 2) ?? 1;
$odds['atq'] = number_format($value['static'][5], 2) ?? 1;
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds = array_merge($odds, $base);
$odds['flags'] = 1;
$res = OddsTq::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
if (! $res) {
OddsTq::create($odds);
} else {
$res->flags = 1;
$res->htq = $odds['htq'];
$res->atq = $odds['atq'];
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}