34 lines
903 B
PHP
34 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
|
|
|
use App\Models\OddsGgng;
|
|
use App\Utilities\Margin;
|
|
|
|
class _Ggng
|
|
{
|
|
public static function grap($odds, $offer)
|
|
{
|
|
foreach ($offer as $value) {
|
|
$odds['gg'] = (float) $value->o1;
|
|
$odds['ng'] = (float) $value->o3;
|
|
}
|
|
$odds['margin'] = (float) Margin::calculate([$odds['gg'], $odds['ng']], 1);
|
|
|
|
$res = OddsGgng::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
|
|
|
|
if (! $res) {
|
|
OddsGgng::create($odds);
|
|
} else {
|
|
$res->gg = $odds['gg'];
|
|
$res->ng = $odds['ng'];
|
|
if ($res->isDirty()) {
|
|
$res->oddchange_at = now();
|
|
}
|
|
$res->checked_at = $odds['checked_at'];
|
|
$res->margin = $odds['margin'];
|
|
$res->save();
|
|
}
|
|
}
|
|
}
|