32 lines
863 B
PHP
32 lines
863 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
|
|
|
use App\Models\OddsGgng;
|
|
use App\Utilities\Margin;
|
|
|
|
class MaglooStoreGgng
|
|
{
|
|
public static function store($value, $base)
|
|
{
|
|
$odds = [];
|
|
$odds['gg'] = number_format($value['static'][74], 2) ?? 1;
|
|
$odds['ng'] = number_format($value['static'][76], 2) ?? 1;
|
|
$odds['margin'] = (float) Margin::calculate($odds, 1);
|
|
$odds['flags'] = 1;
|
|
$odds = array_merge($odds, $base);
|
|
|
|
$res = OddsGgng::where('event_id', $base['event_id'])->where('bookmaker_id', $base['bookmaker_id'])->first();
|
|
|
|
if (! $res) {
|
|
OddsGgng::create($odds);
|
|
} else {
|
|
$res->gg = $odds['gg'];
|
|
$res->ng = $odds['ng'];
|
|
$res->flags = 1;
|
|
$res->margin = $odds['margin'];
|
|
$res->save();
|
|
}
|
|
}
|
|
}
|