From ea0c0a87b05e945a44aedcf6918058f39c06cddd Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Tue, 11 Jun 2024 15:28:06 -0700 Subject: [PATCH 1/2] [TM-754] Respect the filter query param on the tree species API --- .../V2/TreeSpecies/GetTreeSpeciesForEntityController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php b/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php index 26f621b49..9fa869b38 100644 --- a/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php +++ b/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php @@ -7,6 +7,8 @@ use App\Models\V2\EntityModel; use App\Models\V2\TreeSpecies\TreeSpecies; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; +use Spatie\QueryBuilder\QueryBuilder; class GetTreeSpeciesForEntityController extends Controller { @@ -18,6 +20,11 @@ public function __invoke(Request $request, EntityModel $entity) ->where('speciesable_type', get_class($entity)) ->where('speciesable_id', $entity->id); + $filter = $request->query('filter'); + if (! empty($filter['collection'])) { + $query->where('collection', $filter['collection']); + } + return new TreeSpeciesCollection($query->paginate()); } } From a8374f0211f6eb59ce90ad79d8dd4b4baa6f8231 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Tue, 11 Jun 2024 16:09:17 -0700 Subject: [PATCH 2/2] [TM-754] Lint fix --- .../V2/TreeSpecies/GetTreeSpeciesForEntityController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php b/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php index 9fa869b38..0811786c3 100644 --- a/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php +++ b/app/Http/Controllers/V2/TreeSpecies/GetTreeSpeciesForEntityController.php @@ -7,8 +7,6 @@ use App\Models\V2\EntityModel; use App\Models\V2\TreeSpecies\TreeSpecies; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Log; -use Spatie\QueryBuilder\QueryBuilder; class GetTreeSpeciesForEntityController extends Controller {