31 lines
799 B
PHP
31 lines
799 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
|
|
|
use App\Models\OddsDnb;
|
|
use App\Utilities\Margin;
|
|
|
|
class _Dnb
|
|
{
|
|
public static function grap($odds, $offer)
|
|
{
|
|
foreach ($offer as $value) {
|
|
$odds['dnb1'] = (float) $value->o1;
|
|
$odds['dnb2'] = (float) $value->o3;
|
|
}
|
|
$odds['margin'] = (float) Margin::calculate([$odds['dnb1'], $odds['dnb2']], 1);
|
|
|
|
$res = OddsDnb::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
|
|
|
|
if (! $res) {
|
|
OddsDnb::create($odds);
|
|
} else {
|
|
$res->dnb1 = $odds['dnb1'];
|
|
$res->dnb2 = $odds['dnb2'];
|
|
$res->flags = 1;
|
|
$res->margin = $odds['margin'];
|
|
$res->save();
|
|
}
|
|
}
|
|
}
|