Skip to content

Commit

Permalink
Merge pull request #37 from sib-swiss/develop
Browse files Browse the repository at this point in the history
api tags sorting
  • Loading branch information
yhaefligsib authored Oct 18, 2024
2 parents 65eda1a + 0fe1018 commit 8bdeb1f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/Http/Resources/RepositoryFullResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ class RepositoryFullResource extends JsonResource
*/
public function toArray($request)
{
return [
$data = [
'name' => $this->name,
'url' => (string) $this->url,
'website' => (string) $this->website,
'description' => $this->description,
'author' => new AuthorResource($this->whenLoaded('author')),
'tags' => TagResource::collection($this->whenLoaded('tags')),
];

if ($this->relationLoaded('tags')) {
$data['tags'] = TagResource::collection($this->tags->sortBy('pivot.order_column'));
}

$data += [
'days_since_last_push' => $this->days_since_last_push,
'stargazers' => $this->stargazers,
'license' => $this->license,
];

return $data;
}
}

0 comments on commit 8bdeb1f

Please sign in to comment.