diff --git a/src/Request/StoriesRequest.php b/src/Request/StoriesRequest.php index e034c1e..b9b3d47 100644 --- a/src/Request/StoriesRequest.php +++ b/src/Request/StoriesRequest.php @@ -61,6 +61,7 @@ public function __construct( public ?FirstPublishedAtLt $firstPublishedAtLt = null, public ?UpdatedAtGt $updatedAtGt = null, public ?UpdatedAtLt $updatedAtLt = null, + public SlugCollection $bySlugs = new SlugCollection(), ) { Assert::stringNotEmpty($language); Assert::lessThanEq($this->pagination->perPage, self::MAX_PER_PAGE); @@ -168,6 +169,10 @@ public function toArray(): array $array['updated_at_lt'] = $this->updatedAtLt->toString(); } + if ($this->bySlugs->count() > 0) { + $array['by_slugs'] = $this->bySlugs->toString(); + } + return $array; } } diff --git a/tests/Unit/Request/StoriesRequestTest.php b/tests/Unit/Request/StoriesRequestTest.php index c8dda1f..3a9c0dc 100644 --- a/tests/Unit/Request/StoriesRequestTest.php +++ b/tests/Unit/Request/StoriesRequestTest.php @@ -348,4 +348,22 @@ public function toArrayWithUpdatedAtLt(): void 'updated_at_lt' => $expectedDate, ], $request->toArray()); } + + #[Test] + public function toArrayBySlugs(): void + { + $request = new StoriesRequest( + bySlugs: new SlugCollection([ + new Slug('path/*'), + new Slug('another-path/*'), + ]), + ); + + self::assertSame([ + 'language' => 'default', + 'page' => 1, + 'per_page' => 25, + 'by_slugs' => 'path/*,another-path/*', + ], $request->toArray()); + } }