findOne(['slug' => $slug]); if ($fr === null) { throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); } $games = []; foreach ($fr['games'] as $gslug) { $g = (new GameModel())->findBySlug($gslug); if ($g !== null) { $games[] = $g; } } $data = [ 'pageTitle' => $fr['name'] . ' Franchise — GG.deals', 'franchise' => $fr, 'games' => $games, 'allFranchises' => Mongo::collection('franchises')->find([], ['sort' => ['name' => 1]])->toArray(), ]; return view('franchise', $data); } public function all(): string { $list = Mongo::collection('franchises')->find([], ['sort' => ['name' => 1]])->toArray(); $data = [ 'pageTitle' => 'Franchises — GG.deals', 'franchises' => $list, ]; return view('franchises', $data); } }