diff --git a/app/Http/Controllers/PokemonController.php b/app/Http/Controllers/PokemonController.php index 96be273..caf3362 100644 --- a/app/Http/Controllers/PokemonController.php +++ b/app/Http/Controllers/PokemonController.php @@ -12,11 +12,11 @@ public function index(Request $request): \Illuminate\Contracts\View\View|\Illumi { $query = Pokemon::query(); - if (!empty($request->name)) { + if (isset($request->name) && !empty($request->name)) { $query->where('name', 'LIKE', '%' . $request->name . '%'); } - if (!empty($request->type1) && !empty($request->type2)) { + if (isset($request->type1) && !empty($request->type1) && isset($request->type2) && !empty($request->type2)) { if ($request->type2 == "None") { $query->where(function ($q) use ($request) { $q->where('type1_id', $request->type1) @@ -34,13 +34,13 @@ public function index(Request $request): \Illuminate\Contracts\View\View|\Illumi }); } } else { - if (!empty($request->type1filter)) { + if (isset($request->type1) && !empty($request->type1)) { $query->where(function ($q) use ($request) { $q->where('type1_id', $request->type1) ->orWhere('type2_id', $request->type1); }); } - if (!empty($request->type2)) { + if (isset($request->type2) && !empty($request->type2)) { if ($request->type2 == "None") { $query->where('type2_id', null); } else {