Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/Repositories/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function collectFields(RestifyRequest $request)
private function indexFields(RestifyRequest $request): Collection
{
return $this->collectFields($request)
->filter(fn(Field $field) => !$field->isHiddenOnIndex($request, $this))
->filter(fn (Field $field) => ! $field->isHiddenOnIndex($request, $this))
->values();
}

Expand Down Expand Up @@ -298,7 +298,7 @@ public function resolveRelationships($request): array
/** * @var AbstractPaginator $paginator */
$paginator = $this->resource->{$relation}()->paginate($request->get('relatablePerPage') ?? (static::$defaultRelatablePerPage ?? RestifySearchable::DEFAULT_RELATABLE_PER_PAGE));

$withs[$relation] = $paginator->getCollection()->map(fn(Model $item) => [
$withs[$relation] = $paginator->getCollection()->map(fn (Model $item) => [
'attributes' => $item->toArray(),
]);
}
Expand All @@ -318,10 +318,10 @@ public function resolveIndexAttributes($request)
{
// Resolve the show method, and attach the value to the array
$fields = $this->indexFields($request)
->filter(fn(Field $field) => $field->authorize($request))
->each(fn(Field $field) => $field->resolveForIndex($this))
->map(fn(Field $field) => $field->serializeToValue($request))
->mapWithKeys(fn($value) => $value)
->filter(fn (Field $field) => $field->authorize($request))
->each(fn (Field $field) => $field->resolveForIndex($this))
->map(fn (Field $field) => $field->serializeToValue($request))
->mapWithKeys(fn ($value) => $value)
->all();

if ($this instanceof Mergeable) {
Expand All @@ -339,7 +339,7 @@ public function resolveIndexAttributes($request)
return false;
}

if (!$field->authorize($request)) {
if (! $field->authorize($request)) {
return false;
}

Expand Down Expand Up @@ -434,7 +434,7 @@ public function store(RestifyRequest $request)

return $this->response('', RestResponse::REST_RESPONSE_CREATED_CODE)
->model($this->resource)
->header('Location', Restify::path() . '/' . static::uriKey() . '/' . $this->resource->id);
->header('Location', Restify::path().'/'.static::uriKey().'/'.$this->resource->id);
}

public function update(RestifyRequest $request, $repositoryId)
Expand Down Expand Up @@ -632,15 +632,16 @@ public function jsonSerialize()
$data = $data->jsonSerialize();
}

return $this->filter((array)$data);
return $this->filter((array) $data);
}

private function modelAttributes(Request $request = null): Collection
{
return collect(method_exists($this->resource, 'toArray') ? $this->resource->toArray() : []);
}

public static function stored($repository, $request) {
public static function stored($repository, $request)
{
//
}
}