38 lines
1011 B
PHP
38 lines
1011 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
|
|
|
use App\Console\Commands\Nuh;
|
|
use App\Models\OddsDnb;
|
|
use App\Utilities\Margin;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class _Dnb
|
|
{
|
|
public static function grap($odds, $offer)
|
|
{
|
|
$block_update = Nuh::$options['b'] ?? 0;
|
|
|
|
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);
|
|
} elseif (! $block_update) {
|
|
$res->dnb1 = $odds['dnb1'];
|
|
$res->dnb2 = $odds['dnb2'];
|
|
$res->flags = 1;
|
|
$res->margin = $odds['margin'];
|
|
DB::transaction(function () use ($res) {
|
|
$res->save();
|
|
}, 5);
|
|
|
|
}
|
|
}
|
|
}
|