Files
nuhodds_fi4/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php
T
2026-01-18 10:40:19 +01:00

45 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _TotalsHt
{
public static function grap($odds, $offer)
{
foreach ($offer as $value) {
$odds['over'] = (float) $value->o1;
$odds['under'] = (float) $value->o2;
$odds['total'] = (float) $value->o3;
}
if ($odds['sport_id'] == 1) {
if ((float) $odds['total'] != 2.5) {
return;
}
} else {
if (fmod((float) $odds['total'], 1) != 0.5) {
return;
}
}
$odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1);
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds['updated_at'] = now();
DB::table('odds_totals_ht')->upsert(
$odds,
['event_id', 'bookmaker_id', 'total'],
['over', 'under', 'difference', 'margin', 'flags', 'updated_at']
);
ActiveSpread::collect($odds, 'odds_totals_ht');
}
}