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

54 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Call;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Call
*/
class PublicCallResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
...TranslatablePayload::resolve(
$this->resource,
['title', 'slug', 'description', 'what_you_get'],
$locale,
),
'status' => $this->status->value,
// The numbers that let someone decide in ten seconds. Time is the
// scarce resource here, not money.
'hours_per_week' => $this->hours_per_week,
'duration_weeks' => $this->duration_weeks,
'total_hours' => $this->totalHours(),
'seniority' => $this->seniority,
'closes_at' => $this->closes_at?->toDateString(),
'project' => PublicProjectResource::make($this->whenLoaded('project')),
'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')),
'alternates' => SiteUrls::alternates($this->resource, 'call'),
'path' => SiteUrls::alternates($this->resource, 'call')[$locale] ?? null,
];
}
}