public function index() { $dvds = Dvd::take(20)->get(); $genres = $this->findUniqueGenres($dvds); $ratings = $this->findUniqueRatings($dvds); return ['dvds' => $dvds, 'genres' => $genres, 'ratings' => $ratings]; }
public function index() { $dvds = Dvd::take(20)->get(); $dvdEager = Dvd::with('Genre', 'Rating')->take(20)->get(); $genres = $this->findUniqueGenres($dvdEager); $ratings = $this->findUniqueRatings($dvdEager); return ['dvds' => $dvds, 'genres' => $genres, 'ratings' => $ratings]; }