Files
landing-api/app/Http/Resources/PublicApi/PublicIssueResource.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

51 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\RepositoryIssue;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin RepositoryIssue
*
* An open door for someone who has never contributed before.
*/
class PublicIssueResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'number' => $this->number,
'title' => $this->title,
'url' => $this->html_url,
'labels' => $this->labels ?? [],
'is_good_first_issue' => $this->is_good_first_issue,
'is_help_wanted' => $this->is_help_wanted,
// An issue someone has already claimed is not an invitation.
'is_available' => $this->isUnclaimed(),
'comments' => $this->comments,
'created_at' => $this->issue_created_at?->toIso8601String(),
'repository' => $this->whenLoaded('repository', fn () => [
'full_name' => $this->repository->full_name,
'url' => $this->repository->html_url,
'primary_language' => $this->repository->primary_language,
'project' => $this->repository->relationLoaded('project') && $this->repository->project
? [
'title' => $this->repository->project->getTranslation('title', app()->getLocale()),
'slug' => $this->repository->project->getTranslation('slug', app()->getLocale()),
]
: null,
]),
];
}
}