Skip to content

Commit

Permalink
[TM-754] Respect the filter query param on the tree species API
Browse files Browse the repository at this point in the history
  • Loading branch information
roguenet committed Jun 11, 2024
1 parent 03d1862 commit 36f0be2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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());
}
}

0 comments on commit 36f0be2

Please sign in to comment.