public function show($id) { $dvd = Dvd::find($id); if (!$dvd) { return Response::json(['error' => 'Dvd not found'], 404); } $genre[] = Genre::find($dvd->genre_id); $rating[] = Rating::find($dvd->rating_id); return ['dvd' => $dvd, 'genres' => $genre, 'ratings' => $rating]; }
public function showSingleDvd($id) { $dvd = Dvd::find($id); if (!$dvd) { return Response::json(['error' => 'DVD not found'], 404); } $genres = Dvd::find($id)->genre; $ratings = Dvd::find($id)->rating; return ['dvd' => $dvd, 'genres' => [$genres], 'ratings' => [$ratings]]; }
public function show($id) { $dvds = Dvd::find($id); if (!$dvds) { return Response::json(['error' => 'Dvd not found'], 404); } $dvdEager = Dvd::with('Genre', 'Rating')->where('id', '=', "{$id}")->get(); $genres = $this->findUniqueGenres($dvdEager); $ratings = $this->findUniqueRatings($dvdEager); return ['dvd' => $dvds, 'genres' => $genres, 'ratings' => $ratings]; }