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>
44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\PublicApi;
|
|
|
|
use App\Models\Talk;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/**
|
|
* @mixin Talk
|
|
*/
|
|
class PublicTalkResource extends JsonResource
|
|
{
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
$locale = app()->getLocale();
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
|
|
// Not translated: it is the name of a talk that was given once, in
|
|
// one language. `language` says which.
|
|
'title' => $this->title,
|
|
'language' => $this->language,
|
|
|
|
'summary' => $this->getTranslation('summary', $locale, false) ?: null,
|
|
|
|
'event' => $this->event,
|
|
'city' => $this->city,
|
|
'held_at' => $this->held_at?->toDateString(),
|
|
|
|
'video_url' => $this->video_url,
|
|
'slides_url' => $this->slides_url,
|
|
|
|
'speaker' => PublicMemberResource::make($this->whenLoaded('member')),
|
|
];
|
|
}
|
|
}
|