Exemplo n.º 1
0
 public function getSpeakers(string $id_slug = null)
 {
     $single_theme = isset($id_slug);
     if (!$id_slug) {
         /** @var Theme[] $themes */
         $theme = null;
         if (\Auth::check()) {
             $themes = \Auth::user()->all_themes;
         } else {
             $themes = Theme::mostFrequent();
         }
     } else {
         $id = unslug($id_slug)[0];
         $theme = Theme::find($id);
         $themes = [$theme];
         //FIXME: find a way to create a list of "related" themes
     }
     $speakers = [];
     foreach ($themes as $t) {
         //take care to not override $theme
         foreach ($t->sessions as $session) {
             /** @var \App\Models\Session $session */
             $speakers += $session->speakers->all();
         }
     }
     $themed_speakers = (bool) sizeof($speakers);
     if (!$speakers) {
         $speakers = User::findSpeakers();
     }
     return view('user.speakers', compact('theme', 'themes', 'speakers', 'themed_speakers', 'single_theme'));
 }