o1; $odds['under'] = (float) $value->o2; $odds['total'] = (float) $value->o3; } if ($odds['sport_id'] == 1) { if ((float) $odds['total'] != 2.5) { return; } } else { if (fmod((float) $odds['total'], 1) != 0.5) { return; } } if ($odds['over'] >= 1 && $odds['under'] >= 1) { $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); $res = OddsTotalQ1::where('event_id', $odds['event_id']) ->where('bookmaker_id', $odds['bookmaker_id']) ->where('total', $odds['total']) ->first(); if (! $res) { OddsTotalQ1::create($odds); } elseif (! $block_update) { $res->over = $odds['over']; $res->under = $odds['under']; $res->flags = 1; $res->margin = $odds['margin']; DB::transaction(function () use ($res) { $res->save(); }, 5); } } ActiveSpread::collect($odds, 'odds_totals_q1'); } }