From a98ad138f6cb1a476ff680fb59121edfeb4580c3 Mon Sep 17 00:00:00 2001 From: "Hermann D. Schimpf" Date: Thu, 3 Oct 2024 17:53:09 -0400 Subject: [PATCH] FIX: Always convert the `with` param to an array --- src/ResourceRelations.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/ResourceRelations.php b/src/ResourceRelations.php index 7c59faf..e9fe876 100644 --- a/src/ResourceRelations.php +++ b/src/ResourceRelations.php @@ -45,18 +45,8 @@ final public function handle(Builder $query, Closure $next): Builder | Collectio // check if query param wasn't defined and just return if (null !== $with = $this->request->query('with')) { - // convert to array if it is a coma separated string - if (is_string($with) && str_contains($with, ',')) { - $with = explode(',', $with); - } - - // must be an array - if ( !is_array($with)) { - throw new InvalidArgumentException( - message: 'Parameter "with" must be an array.', - code: Response::HTTP_BAD_REQUEST, - ); - } + // convert to array if it is a string + $with = is_string($with) ? explode(',', $with) : $with; foreach ($this->allowed_relations as $mapping => $relation_name) { if (is_int($mapping)) {