38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
|
|
|
use App\Models\Odds3way;
|
|
use App\Utilities\Margin;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class MaglooStore1x2
|
|
{
|
|
public static function store($value, $base)
|
|
{
|
|
$odds = [];
|
|
$odds['h3w'] = number_format($value['static'][1], 2) ?? 1;
|
|
$odds['d3w'] = number_format($value['static'][2], 2) ?? 1;
|
|
$odds['a3w'] = number_format($value['static'][3], 2) ?? 1;
|
|
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
|
$odds['flags'] = 1;
|
|
$odds = array_merge($odds, $base);
|
|
|
|
$res = Odds3way::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
|
|
if (! $res) {
|
|
Odds3way::create($odds);
|
|
} else {
|
|
$res->h3w = $odds['h3w'];
|
|
$res->d3w = $odds['d3w'];
|
|
$res->a3w = $odds['a3w'];
|
|
$res->flags = 1;
|
|
$res->margin = $odds['margin'];
|
|
DB::transaction(function () use ($res) {
|
|
$res->save();
|
|
usleep(250000);
|
|
}, 5);
|
|
|
|
}
|
|
}
|
|
}
|