Files
nuhodds_fi4/app/Console/Commands/Grapper/Logifuture/Tools/LogifutureStorePoints.php
T
2026-02-07 07:08:58 +01:00

50 lines
1.5 KiB
PHP

<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsPoint;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin;
class LogifutureStorePoints
{
public static function store(&$_spreads, $base)
{
ActiveHandicap::set($_spreads);
foreach ($_spreads as $handicap => $value) {
// code...
$odds = [];
$odds['home'] = $value['ele1'];
$odds['away'] = $value['ele2'];
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['active_spread'] = $value['active_spread'];
$odds['handicap'] = $handicap;
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsPoint::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPoint::create($odds);
} else {
$res->home = number_format($odds['home'], 2);
$res->away = number_format($odds['away'], 2);
$res->handicap = number_format($odds['handicap'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->flags = 1;
$res->margin = $odds['margin'];
DatabaseFunctions::save_update($res);
}
}
}
}