From 36f0be21ead0fb0160c2e0184d0dec2243cdb50c 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 060b95fe4887d2c4ede4ae5fd7e96afe96e30306 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 {