Skip to content

Commit

Permalink
FIX: Always convert the with param to an array
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimpf committed Oct 3, 2024
1 parent 0fb48e9 commit a98ad13
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/ResourceRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit a98ad13

Please sign in to comment.