input('query'); $type = $request->input('type', 'all'); $movies = collect([]); $shows = collect([]); $people = collect([]); if ($query) { // Search for movies if type is 'all' or 'movie' if ($type === 'all' || $type === 'movie') { $movies = Movie::where('title', 'like', "%{$query}%") ->orWhere('overview', 'like', "%{$query}%") ->limit(20) ->get(); } // Search for TV shows if type is 'all' or 'tv' if ($type === 'all' || $type === 'tv') { $shows = Show::where('name', 'like', "%{$query}%") ->orWhere('overview', 'like', "%{$query}%") ->limit(20) ->get(); } // Search for people if type is 'all' or 'person' if ($type === 'all' || $type === 'person') { $people = Person::where('name', 'like', "%{$query}%") ->limit(20) ->get(); } } return view('search.results', [ 'query' => $query, 'type' => $type, 'movies' => $movies, 'shows' => $shows, 'people' => $people, ]); } }