Files
landing-api/app/Http/Resources/PublicApi/PublicRepositoryResource.php
Josep Piguillem 3897113313 Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer
collective, backed by the Pireon OAuth identity server. The public site is a
separate, server-rendered application consuming /api/public/v1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 17:55:27 +02:00

50 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Repository;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Repository
*/
class PublicRepositoryResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'provider' => $this->provider->value,
'full_name' => $this->full_name,
'url' => $this->html_url,
'description' => $this->description,
'primary_language' => $this->primary_language,
'languages' => (object) ($this->languages ?? []),
'topics' => $this->topics ?? [],
'license' => $this->license,
'stars' => $this->stars,
'forks' => $this->forks,
'contributors_count' => $this->contributors_count,
'open_issues_count' => $this->open_issues_count,
'is_archived' => $this->is_archived,
// Lets the frontend avoid presenting dead work as live.
'is_dormant' => $this->isDormant(),
'pushed_at' => $this->pushed_at?->toIso8601String(),
'synced_at' => $this->last_synced_at?->toIso8601String(),
'good_first_issues' => PublicIssueResource::collection($this->whenLoaded('goodFirstIssues')),
'issues' => PublicIssueResource::collection($this->whenLoaded('issues')),
];
}
}