o1; $odds['d3w'] = (float) $value->o2; $odds['a3w'] = (float) $value->o3; } $odds['margin'] = (float) Margin::calculate([$odds['h3w'], $odds['d3w'], $odds['a3w']], 1); $res = Odds3way::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first(); if (! $res) { Odds3way::create($odds); } elseif (! $block_update) { $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(); }, 5); } } }