From d00b49a53cc1ecef467b76d61b84b536c68e2d52 Mon Sep 17 00:00:00 2001 From: Nikolai Shangin Date: Mon, 17 Mar 2025 17:36:03 +0500 Subject: [PATCH 1/2] Update the schema stub to use iterable types for the fields and filters methods, enhancing type consistency and clarity. Additionally, include the Filter contract for improved functionality. --- stubs/schema.stub | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stubs/schema.stub b/stubs/schema.stub index f407282..239c39a 100644 --- a/stubs/schema.stub +++ b/stubs/schema.stub @@ -3,6 +3,7 @@ namespace {{ namespace }}; use {{ namespacedModel }}; +use LaravelJsonApi\Eloquent\Contracts\Filter; use LaravelJsonApi\Eloquent\Contracts\Paginator; use LaravelJsonApi\Eloquent\Fields\DateTime; use LaravelJsonApi\Eloquent\Fields\ID; @@ -23,9 +24,9 @@ class {{ class }} extends {{ schema }} /** * Get the resource fields. * - * @return array + * @return iterable */ - public function fields(): array + public function fields(): iterable { return [ ID::make(), @@ -37,9 +38,9 @@ class {{ class }} extends {{ schema }} /** * Get the resource filters. * - * @return array + * @return iterable */ - public function filters(): array + public function filters(): iterable { return [ WhereIdIn::make($this), From d00b8cfc87d96b494d6d9a7868e639cec2b453b2 Mon Sep 17 00:00:00 2001 From: Nikolai Shangin Date: Sat, 22 Mar 2025 09:19:53 +0500 Subject: [PATCH 2/2] Return types to array, but retain typehints --- stubs/schema.stub | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/schema.stub b/stubs/schema.stub index 239c39a..555ed00 100644 --- a/stubs/schema.stub +++ b/stubs/schema.stub @@ -24,9 +24,9 @@ class {{ class }} extends {{ schema }} /** * Get the resource fields. * - * @return iterable + * @return array */ - public function fields(): iterable + public function fields(): array { return [ ID::make(), @@ -38,9 +38,9 @@ class {{ class }} extends {{ schema }} /** * Get the resource filters. * - * @return iterable + * @return array */ - public function filters(): iterable + public function filters(): array { return [ WhereIdIn::make($this),