settings = MultilineSetting::where('id', auth()->user()->multiline_setting_id)->select('table', 'has_3_columns')->first()->toArray(); $odds = DB::table($this->settings['table'])->where('event_id', $event_id)->get(); $this->makeSlots($odds, $bookmakers); } public function has3Columns(): ?int { return $this->settings['has_3_columns']; } public function getSlots(): ?array { return $this->slots; } public function makeSlots(&$odds, $bookmakers) { $multilines = []; foreach ($bookmakers as $slot => $bookmaker) { $open = true; foreach ($odds as $item) { if ($item->bookmaker_id == $bookmaker->bookmaker_id) { $item->icon = $bookmaker->bookmaker->icon; $item->table = $this->settings['table']; switch ($this->settings['table']) { case 'odds_2ways': case 'odds_2ways_s1': $item->a = $item->h3w; $item->c = $item->a3w; break; case 'odds_3ways': $item->a = $item->h3w; $item->b = $item->d3w; $item->c = $item->a3w; break; case 'odds_dc': $item->a = $item->dc1x; $item->b = $item->dc12; $item->c = $item->dc2x; break; case 'odds_dnb': $item->a = $item->dnb1; $item->c = $item->dnb2; break; case 'odds_ggng': $item->a = $item->gg; $item->c = $item->ng; break; case 'odds_handicaps': case 'odds_handicaps_q1': $item->a = $item->home; $item->b = $item->away; $item->c = $item->handicap; break; case 'odds_qualify': $item->a = $item->htq; $item->c = $item->atq; break; case 'odds_totals': case 'odds_totals_q1': $item->a = $item->over; $item->b = $item->under; $item->c = $item->total; break; default: // code... break; } $multilines[$slot] = $item; $open = false; } } if ($open) { $item = new stdClass; $item->bookmaker_id = $bookmaker->bookmaker_id; $item->icon = $bookmaker->bookmaker->icon; $item->a = 0; $item->b = 0; $item->c = 0; $item->marging = 0; $multilines[$slot] = $item; } } $this->slots = $multilines; } }