diff --git a/src/Concerns/Resource/ConfiguresRestParameters.php b/src/Concerns/Resource/ConfiguresRestParameters.php index 283d9e7..2f3e7af 100644 --- a/src/Concerns/Resource/ConfiguresRestParameters.php +++ b/src/Concerns/Resource/ConfiguresRestParameters.php @@ -10,24 +10,24 @@ trait ConfiguresRestParameters { /** - * The exposed fields that could be provided + * The fields that could be provided * @param RestRequest $request * @return array */ - public function exposedFields(RestRequest $request): array { + public function fields(RestRequest $request): array { return []; } - public function getNestedExposedFields(RestRequest $request, string $prefix = '', array $loadedRelations = []) { + public function getNestedFields(RestRequest $request, string $prefix = '', array $loadedRelations = []) { if ($prefix !== '') { $prefix = $prefix.'.'; } - $exposedFields = array_map( - function ($exposedField) use ($prefix) { - return $prefix.$exposedField; + $fields = array_map( + function ($field) use ($prefix) { + return $prefix.$field; }, - $this->exposedFields($request) + $this->fields($request) ); foreach ( @@ -39,8 +39,8 @@ function ($exposedField) use ($prefix) { ) { $loadedRelations[] = $relation->relation; array_push( - $exposedFields, - ...$relation->resource()->getNestedExposedFields($request, $prefix.$relation->relation,$loadedRelations), + $fields, + ...$relation->resource()->getNestedFields($request, $prefix.$relation->relation,$loadedRelations), // We push the pivot fields if they exists ...( collect(method_exists($relation, 'getPivotFields') ? $relation->getPivotFields() : []) @@ -49,24 +49,24 @@ function ($exposedField) use ($prefix) { ); } - return $exposedFields; + return $fields; } /** - * The exposed scopes that could be provided + * The scopes that could be provided * @param RestRequest $request * @return array */ - public function exposedScopes(RestRequest $request): array { + public function scopes(RestRequest $request): array { return []; } /** - * The exposed limits that could be provided + * The limits that could be provided * @param RestRequest $request * @return array */ - public function exposedLimits(RestRequest $request): array { + public function limits(RestRequest $request): array { return [ 10, 25, diff --git a/src/Concerns/Resource/Relationable.php b/src/Concerns/Resource/Relationable.php index 4750bf4..08bc23d 100644 --- a/src/Concerns/Resource/Relationable.php +++ b/src/Concerns/Resource/Relationable.php @@ -54,7 +54,7 @@ public function nestedRelations(RestRequest $request, string $prefix = '', array } /** - * The exposed relations that could be provided + * The relations that could be provided * @param RestRequest $request * @return array */ diff --git a/src/Console/stubs/resource.stub b/src/Console/stubs/resource.stub index 6c45f22..3337a02 100644 --- a/src/Console/stubs/resource.stub +++ b/src/Console/stubs/resource.stub @@ -18,7 +18,7 @@ class {{ class }} extends RestResource * @param RestRequest $request * @return array */ - public function exposedFields(\Lomkit\Rest\Http\Requests\RestRequest $request): array + public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request): array { return [ 'id' @@ -40,7 +40,7 @@ class {{ class }} extends RestResource * @param RestRequest $request * @return array */ - public function exposedScopes(\Lomkit\Rest\Http\Requests\RestRequest $request): array + public function scopes(\Lomkit\Rest\Http\Requests\RestRequest $request): array { return []; } @@ -50,7 +50,7 @@ class {{ class }} extends RestResource * @param RestRequest $request * @return array */ - public function exposedLimits(\Lomkit\Rest\Http\Requests\RestRequest $request): array + public function limits(\Lomkit\Rest\Http\Requests\RestRequest $request): array { return [ 10, diff --git a/src/Console/stubs/user-resource.stub b/src/Console/stubs/user-resource.stub index 051d9c4..0ed81cc 100644 --- a/src/Console/stubs/user-resource.stub +++ b/src/Console/stubs/user-resource.stub @@ -18,7 +18,7 @@ class User extends RestResource * @param RestRequest $request * @return array */ - public function exposedFields(\Lomkit\Rest\Http\Requests\RestRequest $request) + public function fields(\Lomkit\Rest\Http\Requests\RestRequest $request) { return [ 'id', @@ -42,7 +42,7 @@ class User extends RestResource * @param RestRequest $request * @return array */ - public function exposedScopes(\Lomkit\Rest\Http\Requests\RestRequest $request) { + public function scopes(\Lomkit\Rest\Http\Requests\RestRequest $request) { return []; } @@ -51,7 +51,7 @@ class User extends RestResource * @param RestRequest $request * @return array */ - public function exposedLimits(\Lomkit\Rest\Http\Requests\RestRequest $request) { + public function limits(\Lomkit\Rest\Http\Requests\RestRequest $request) { return [ 10, 25, diff --git a/src/Http/Requests/MutateRequest.php b/src/Http/Requests/MutateRequest.php index 17aba3b..2c1d267 100644 --- a/src/Http/Requests/MutateRequest.php +++ b/src/Http/Requests/MutateRequest.php @@ -37,7 +37,7 @@ public function mutateRules(Resource $resource, $prefix = 'mutate.*', $loadedRel $prefix.'.attributes' => [ 'prohibited_if:'.$prefix.'.operation,attach', 'prohibited_if:'.$prefix.'.operation,detach', - 'array:'.Arr::join($resource->exposedFields($this), ',') + 'array:'.Arr::join($resource->fields($this), ',') ], $prefix.'.key' => [ 'required_if:'.$prefix.'.operation,update', diff --git a/src/Http/Requests/SearchRequest.php b/src/Http/Requests/SearchRequest.php index 069e273..1c3555f 100644 --- a/src/Http/Requests/SearchRequest.php +++ b/src/Http/Requests/SearchRequest.php @@ -40,7 +40,7 @@ public function searchRules(Resource $resource, $prefix = '', $isRootSearchRules [$prefix.'instructions' => ['sometimes', 'array']], $this->instructionsRules($resource, $prefix.'instructions'), [ - 'limit' => ['sometimes', 'integer', Rule::in($resource->exposedLimits($this))], + 'limit' => ['sometimes', 'integer', Rule::in($resource->limits($this))], 'page' => ['sometimes', 'integer'] ], $isRootSearchRules ? ['includes' => ['sometimes', 'array']] : [], @@ -53,7 +53,7 @@ public function filtersRules(Resource $resource, string $prefix, $isMaxDepth = f $rules = array_merge( [ $prefix.'.*.field' => [ - Rule::in($resource->getNestedExposedFields($this)), + Rule::in($resource->getNestedFields($this)), "required_without:$prefix.*.nested", 'string' ], @@ -86,7 +86,7 @@ public function filtersRules(Resource $resource, string $prefix, $isMaxDepth = f protected function scopesRules(Resource $resource, string $prefix) { $rules = [ $prefix.'.*.name' => [ - Rule::in($resource->exposedScopes($this)), + Rule::in($resource->scopes($this)), 'required', 'string' ], @@ -126,7 +126,7 @@ protected function instructionsRules(Resource $resource, string $prefix) { protected function sortsRules(Resource $resource, string $prefix) { $rules = [ $prefix.'.*.field' => [ - Rule::in($resource->exposedFields($this)), + Rule::in($resource->fields($this)), 'required', 'string' ], @@ -142,7 +142,7 @@ protected function sortsRules(Resource $resource, string $prefix) { protected function selectsRules(Resource $resource, string $prefix) { $rules = [ $prefix.'.*.field' => [ - Rule::in($resource->exposedFields($this)), + Rule::in($resource->fields($this)), 'required', 'string' ] diff --git a/src/Http/Resource.php b/src/Http/Resource.php index 0c17d0e..0f04def 100644 --- a/src/Http/Resource.php +++ b/src/Http/Resource.php @@ -87,9 +87,9 @@ public function jsonSerialize(): mixed return [ 'actions' => collect($this->actions($request))->map->jsonSerialize()->toArray(), 'instructions' => collect($this->instructions($request))->map->jsonSerialize()->toArray(), - 'fields' => $this->exposedFields($request), - 'limits' => $this->exposedLimits($request), - 'scopes' => $this->exposedScopes($request), + 'fields' => $this->fields($request), + 'limits' => $this->limits($request), + 'scopes' => $this->scopes($request), 'relations' => collect($this->relations($request))->map->jsonSerialize()->toArray(), 'rules' => [ 'all' => $this->rules($request), diff --git a/src/Http/Response.php b/src/Http/Response.php index 080f350..8b6ecc0 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -53,7 +53,7 @@ public function modelToResponse(Model $model, Resource $resource, array $request array_merge( isset($requestArray['selects']) ? collect($requestArray['selects'])->pluck('field')->toArray() : - $resource->exposedFields(app()->make(RestRequest::class)), + $resource->fields(app()->make(RestRequest::class)), // Here we add the aggregates collect($requestArray['aggregates'] ?? []) ->map(function ($aggregate) { diff --git a/src/Rules/AggregateField.php b/src/Rules/AggregateField.php index 0ab5bd5..cb484b1 100644 --- a/src/Rules/AggregateField.php +++ b/src/Rules/AggregateField.php @@ -88,7 +88,7 @@ protected function buildValidationRules($attribute, $value) return [ $attribute.'.field' => \Illuminate\Validation\Rule::in( - $relationResource->exposedFields(app()->make(RestRequest::class)) + $relationResource->fields(app()->make(RestRequest::class)) ) ]; } diff --git a/tests/Feature/Controllers/AutomaticGatingTest.php b/tests/Feature/Controllers/AutomaticGatingTest.php index 2f7046c..5e9b76f 100644 --- a/tests/Feature/Controllers/AutomaticGatingTest.php +++ b/tests/Feature/Controllers/AutomaticGatingTest.php @@ -356,7 +356,7 @@ public function test_searching_automatic_gated_resource_with_belongs_to_many_rel ->get() ->map(function ($relation) use ($matchingModel, $pivotAccessor) { return collect($relation->only( - array_merge((new BelongsToManyResource)->exposedFields(app()->make(RestRequest::class)), [$pivotAccessor]) + array_merge((new BelongsToManyResource)->fields(app()->make(RestRequest::class)), [$pivotAccessor]) )) ->pipe(function ($relation) use ($matchingModel, $pivotAccessor) { $relation[$pivotAccessor] = collect($relation[$pivotAccessor]->toArray()) diff --git a/tests/Feature/Controllers/SearchIncludingMorphRelationshipsOperationsTest.php b/tests/Feature/Controllers/SearchIncludingMorphRelationshipsOperationsTest.php index f0d988a..773f30f 100644 --- a/tests/Feature/Controllers/SearchIncludingMorphRelationshipsOperationsTest.php +++ b/tests/Feature/Controllers/SearchIncludingMorphRelationshipsOperationsTest.php @@ -71,7 +71,7 @@ public function test_getting_a_list_of_resources_including_morph_to_relation(): new ModelResource, [ [ - 'morph_to_relation' => $matchingModel->morphToRelation->only((new MorphToResource)->exposedFields(app()->make(RestRequest::class))), + 'morph_to_relation' => $matchingModel->morphToRelation->only((new MorphToResource)->fields(app()->make(RestRequest::class))), ], [ 'morph_to_relation' => null, @@ -111,7 +111,7 @@ public function test_getting_a_list_of_resources_including_morph_one_relation(): [ [ 'morph_one_relation' => $matchingModel->morphOneRelation->only( - (new MorphOneResource)->exposedFields(app()->make(RestRequest::class)) + (new MorphOneResource)->fields(app()->make(RestRequest::class)) ), ], [ @@ -152,7 +152,7 @@ public function test_getting_a_list_of_resources_including_morph_one_of_many_rel [ [ 'morph_one_of_many_relation' => $matchingModel->morphOneOfManyRelation->only( - (new MorphOneOfManyResource)->exposedFields(app()->make(RestRequest::class)) + (new MorphOneOfManyResource)->fields(app()->make(RestRequest::class)) ), ], [ @@ -199,7 +199,7 @@ public function test_getting_a_list_of_resources_including_morph_many_relation() ->get() ->map(function ($relation) { return $relation->only( - (new MorphManyResource)->exposedFields(app()->make(RestRequest::class)) + (new MorphManyResource)->fields(app()->make(RestRequest::class)) ); })->toArray(), ], @@ -245,7 +245,7 @@ public function test_getting_a_list_of_resources_including_morph_to_many_relatio ->get() ->map(function ($relation) use ($matchingModel, $pivotAccessor) { return collect($relation->only( - array_merge((new MorphToManyResource)->exposedFields(app()->make(RestRequest::class)), [$pivotAccessor]) + array_merge((new MorphToManyResource)->fields(app()->make(RestRequest::class)), [$pivotAccessor]) )) ->pipe(function ($relation) use ($matchingModel, $pivotAccessor) { $relation[$pivotAccessor] = collect($relation[$pivotAccessor]->toArray()) @@ -299,7 +299,7 @@ public function test_getting_a_list_of_resources_including_morphed_by_many_relat ->get() ->map(function ($relation) use ($matchingModel, $pivotAccessor) { return collect($relation->only( - array_merge((new MorphedByManyResource)->exposedFields(app()->make(RestRequest::class)), [$pivotAccessor]) + array_merge((new MorphedByManyResource)->fields(app()->make(RestRequest::class)), [$pivotAccessor]) )) ->pipe(function ($relation) use ($matchingModel, $pivotAccessor) { $relation[$pivotAccessor] = collect($relation[$pivotAccessor]->toArray()) diff --git a/tests/Feature/Controllers/SearchIncludingRelationshipsOperationsTest.php b/tests/Feature/Controllers/SearchIncludingRelationshipsOperationsTest.php index 55b6cef..c61c956 100644 --- a/tests/Feature/Controllers/SearchIncludingRelationshipsOperationsTest.php +++ b/tests/Feature/Controllers/SearchIncludingRelationshipsOperationsTest.php @@ -75,7 +75,7 @@ public function test_getting_a_list_of_resources_including_belongs_to_relation() new ModelResource, [ [ - 'belongs_to_relation' => $matchingModel->belongsToRelation->only((new BelongsToResource)->exposedFields(app()->make(RestRequest::class))), + 'belongs_to_relation' => $matchingModel->belongsToRelation->only((new BelongsToResource)->fields(app()->make(RestRequest::class))), ], [ 'belongs_to_relation' => null, @@ -116,11 +116,11 @@ public function test_getting_a_list_of_resources_including_belongs_to_has_many_r [ 'belongs_to_relation' => array_merge( $matchingModelBelongsToRelation - ->only((new BelongsToResource)->exposedFields(app()->make(RestRequest::class))), + ->only((new BelongsToResource)->fields(app()->make(RestRequest::class))), [ 'models' => $matchingModelBelongsToRelation->models ->map(function($model) { - return $model->only((new ModelResource)->exposedFields(app()->make(RestRequest::class))); + return $model->only((new ModelResource)->fields(app()->make(RestRequest::class))); }) ->toArray(), ] @@ -164,7 +164,7 @@ public function test_getting_a_list_of_resources_including_has_one_relation(): v [ [ 'has_one_relation' => $matchingModel->hasOneRelation->only( - (new HasOneResource)->exposedFields(app()->make(RestRequest::class)) + (new HasOneResource)->fields(app()->make(RestRequest::class)) ), ], [ @@ -205,7 +205,7 @@ public function test_getting_a_list_of_resources_including_has_one_of_many_relat [ [ 'has_one_of_many_relation' => $matchingModel->hasOneOfManyRelation->only( - (new HasOneOfManyResource)->exposedFields(app()->make(RestRequest::class)) + (new HasOneOfManyResource)->fields(app()->make(RestRequest::class)) ), ], [ @@ -252,7 +252,7 @@ public function test_getting_a_list_of_resources_including_has_many_relation(): ->get() ->map(function ($relation) { return $relation->only( - (new HasManyResource)->exposedFields(app()->make(RestRequest::class)) + (new HasManyResource)->fields(app()->make(RestRequest::class)) ); })->toArray(), ], @@ -298,7 +298,7 @@ public function test_getting_a_list_of_resources_including_belongs_to_many_relat ->get() ->map(function ($relation) use ($matchingModel, $pivotAccessor) { return collect($relation->only( - array_merge((new BelongsToManyResource)->exposedFields(app()->make(RestRequest::class)), [$pivotAccessor]) + array_merge((new BelongsToManyResource)->fields(app()->make(RestRequest::class)), [$pivotAccessor]) )) ->pipe(function ($relation) use ($matchingModel, $pivotAccessor) { $relation[$pivotAccessor] = collect($relation[$pivotAccessor]->toArray()) diff --git a/tests/Feature/Controllers/SearchIncludingThroughRelationshipsOperationsTest.php b/tests/Feature/Controllers/SearchIncludingThroughRelationshipsOperationsTest.php index 0d253ef..4b47d0f 100644 --- a/tests/Feature/Controllers/SearchIncludingThroughRelationshipsOperationsTest.php +++ b/tests/Feature/Controllers/SearchIncludingThroughRelationshipsOperationsTest.php @@ -62,7 +62,7 @@ public function test_getting_a_list_of_resources_including_has_one_through_relat new ModelResource, [ [ - 'has_one_through_relation' => $matchingModel->hasOneThroughRelation->only((new HasOneThroughResource())->exposedFields(app()->make(RestRequest::class))), + 'has_one_through_relation' => $matchingModel->hasOneThroughRelation->only((new HasOneThroughResource())->fields(app()->make(RestRequest::class))), ], [ 'has_one_through_relation' => null, @@ -105,7 +105,7 @@ public function test_getting_a_list_of_resources_including_has_many_through_rela [ 'has_many_through_relation' => $matchingModel->hasManyThroughRelation->map(function ($relation) { return $relation->only( - (new HasManyThroughResource)->exposedFields(app()->make(RestRequest::class)) + (new HasManyThroughResource)->fields(app()->make(RestRequest::class)) ); })->toArray(), ], diff --git a/tests/Support/Rest/Resources/AutomaticGatingResource.php b/tests/Support/Rest/Resources/AutomaticGatingResource.php index eee94ae..04c0a20 100644 --- a/tests/Support/Rest/Resources/AutomaticGatingResource.php +++ b/tests/Support/Rest/Resources/AutomaticGatingResource.php @@ -36,7 +36,7 @@ public function relations(RestRequest $request): array ]; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/BelongsToManyResource.php b/tests/Support/Rest/Resources/BelongsToManyResource.php index 2ee5063..4da03c0 100644 --- a/tests/Support/Rest/Resources/BelongsToManyResource.php +++ b/tests/Support/Rest/Resources/BelongsToManyResource.php @@ -18,7 +18,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/BelongsToResource.php b/tests/Support/Rest/Resources/BelongsToResource.php index f883f76..d3e2833 100644 --- a/tests/Support/Rest/Resources/BelongsToResource.php +++ b/tests/Support/Rest/Resources/BelongsToResource.php @@ -22,7 +22,7 @@ public function relations(RestRequest $request): array ]; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/HasManyResource.php b/tests/Support/Rest/Resources/HasManyResource.php index db1f85c..efe7dfd 100644 --- a/tests/Support/Rest/Resources/HasManyResource.php +++ b/tests/Support/Rest/Resources/HasManyResource.php @@ -18,7 +18,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/HasManyThroughResource.php b/tests/Support/Rest/Resources/HasManyThroughResource.php index 3d59501..4f0a4a5 100644 --- a/tests/Support/Rest/Resources/HasManyThroughResource.php +++ b/tests/Support/Rest/Resources/HasManyThroughResource.php @@ -20,7 +20,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/HasOneOfManyResource.php b/tests/Support/Rest/Resources/HasOneOfManyResource.php index 0f5248e..58e9dce 100644 --- a/tests/Support/Rest/Resources/HasOneOfManyResource.php +++ b/tests/Support/Rest/Resources/HasOneOfManyResource.php @@ -20,7 +20,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/HasOneResource.php b/tests/Support/Rest/Resources/HasOneResource.php index 4d5aec1..9a10b63 100644 --- a/tests/Support/Rest/Resources/HasOneResource.php +++ b/tests/Support/Rest/Resources/HasOneResource.php @@ -18,7 +18,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/HasOneThroughResource.php b/tests/Support/Rest/Resources/HasOneThroughResource.php index 460c16e..cbcf2b6 100644 --- a/tests/Support/Rest/Resources/HasOneThroughResource.php +++ b/tests/Support/Rest/Resources/HasOneThroughResource.php @@ -20,7 +20,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/ModelResource.php b/tests/Support/Rest/Resources/ModelResource.php index 9134d50..0991443 100644 --- a/tests/Support/Rest/Resources/ModelResource.php +++ b/tests/Support/Rest/Resources/ModelResource.php @@ -76,7 +76,7 @@ public function relations(RestRequest $request): array ]; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', @@ -87,11 +87,11 @@ public function exposedFields(RestRequest $request): array } /** - * The exposed scopes that could be provided + * The scopes that could be provided * @param RestRequest $request * @return array */ - public function exposedScopes(RestRequest $request): array + public function scopes(RestRequest $request): array { return [ 'numbered' @@ -99,11 +99,11 @@ public function exposedScopes(RestRequest $request): array } /** - * The exposed limits that could be provided + * The limits that could be provided * @param RestRequest $request * @return array */ - public function exposedLimits(RestRequest $request): array { + public function limits(RestRequest $request): array { return [ 1, 10, diff --git a/tests/Support/Rest/Resources/MorphManyResource.php b/tests/Support/Rest/Resources/MorphManyResource.php index 423e68f..8a20d03 100644 --- a/tests/Support/Rest/Resources/MorphManyResource.php +++ b/tests/Support/Rest/Resources/MorphManyResource.php @@ -22,7 +22,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/MorphOneOfManyResource.php b/tests/Support/Rest/Resources/MorphOneOfManyResource.php index 4aa8d9a..41e1d4b 100644 --- a/tests/Support/Rest/Resources/MorphOneOfManyResource.php +++ b/tests/Support/Rest/Resources/MorphOneOfManyResource.php @@ -18,7 +18,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/MorphOneResource.php b/tests/Support/Rest/Resources/MorphOneResource.php index 9239599..a558bb1 100644 --- a/tests/Support/Rest/Resources/MorphOneResource.php +++ b/tests/Support/Rest/Resources/MorphOneResource.php @@ -21,7 +21,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/MorphToManyResource.php b/tests/Support/Rest/Resources/MorphToManyResource.php index cc5de9b..8f2f33c 100644 --- a/tests/Support/Rest/Resources/MorphToManyResource.php +++ b/tests/Support/Rest/Resources/MorphToManyResource.php @@ -19,7 +19,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/MorphToResource.php b/tests/Support/Rest/Resources/MorphToResource.php index 8dcc7b0..13ecc7f 100644 --- a/tests/Support/Rest/Resources/MorphToResource.php +++ b/tests/Support/Rest/Resources/MorphToResource.php @@ -20,7 +20,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/MorphedByManyResource.php b/tests/Support/Rest/Resources/MorphedByManyResource.php index 940240e..6562e79 100644 --- a/tests/Support/Rest/Resources/MorphedByManyResource.php +++ b/tests/Support/Rest/Resources/MorphedByManyResource.php @@ -21,7 +21,7 @@ public function relations(RestRequest $request): array return []; } - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/NoAuthorizationResource.php b/tests/Support/Rest/Resources/NoAuthorizationResource.php index da2d8c0..c207459 100644 --- a/tests/Support/Rest/Resources/NoAuthorizationResource.php +++ b/tests/Support/Rest/Resources/NoAuthorizationResource.php @@ -27,7 +27,7 @@ class NoAuthorizationResource extends Resource public static $model = Model::class; - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id', diff --git a/tests/Support/Rest/Resources/NoExposedFieldsResource.php b/tests/Support/Rest/Resources/NoExposedFieldsResource.php index ee6dcc2..7e0bb36 100644 --- a/tests/Support/Rest/Resources/NoExposedFieldsResource.php +++ b/tests/Support/Rest/Resources/NoExposedFieldsResource.php @@ -17,7 +17,7 @@ class NoExposedFieldsResource extends Resource public static $model = Model::class; - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return []; } diff --git a/tests/Support/Rest/Resources/SoftDeletedModelResource.php b/tests/Support/Rest/Resources/SoftDeletedModelResource.php index 9e8a420..7c283ad 100644 --- a/tests/Support/Rest/Resources/SoftDeletedModelResource.php +++ b/tests/Support/Rest/Resources/SoftDeletedModelResource.php @@ -18,7 +18,7 @@ class SoftDeletedModelResource extends Resource public static $model = SoftDeletedModel::class; - public function exposedFields(RestRequest $request): array + public function fields(RestRequest $request): array { return [ 'id' diff --git a/tests/Support/Traits/InteractsWithResource.php b/tests/Support/Traits/InteractsWithResource.php index d434a2c..5e83133 100644 --- a/tests/Support/Traits/InteractsWithResource.php +++ b/tests/Support/Traits/InteractsWithResource.php @@ -31,7 +31,7 @@ protected function assertResourcePaginated($response, $models, Resource $resourc $this->assertEquals( collect($models) ->map(function ($model) use ($resource) { - return $model->only($resource->exposedFields(App::make(RestRequest::class))); + return $model->only($resource->fields(App::make(RestRequest::class))); }) ->when(!empty($additionalFields), function (Collection $collection) use ($additionalFields) { return $collection @@ -55,7 +55,7 @@ protected function assertResourceModel($response, $models, Resource $resource) { $this->assertEquals( array_map( function($model) use ($resource) { - return $model->only($resource->exposedFields(App::make(RestRequest::class))); + return $model->only($resource->fields(App::make(RestRequest::class))); }, $models ),