2026-03-29 22:24:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Resources\Api;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
|
|
class PostPlatformResource extends JsonResource
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @return array<string, mixed>
|
|
|
|
|
*/
|
|
|
|
|
public function toArray(Request $request): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'id' => $this->id,
|
2026-05-04 00:34:20 +00:00
|
|
|
'platform' => $this->platform?->value,
|
|
|
|
|
'content_type' => $this->content_type?->value,
|
2026-06-10 18:36:47 +00:00
|
|
|
'meta' => $this->meta,
|
2026-05-04 00:34:20 +00:00
|
|
|
'status' => $this->status?->value,
|
2026-03-29 22:24:28 +00:00
|
|
|
'enabled' => $this->enabled,
|
2026-05-04 01:11:58 +00:00
|
|
|
'platform_url' => $this->platform_url,
|
|
|
|
|
'published_at' => $this->published_at?->format('Y-m-d H:i:s'),
|
|
|
|
|
'error_message' => $this->error_message,
|
|
|
|
|
// Display fields fall back to snapshots (platform_name/username/avatar)
|
|
|
|
|
// so deleted accounts still render correctly in the post history.
|
|
|
|
|
'display_name' => $this->display_name,
|
|
|
|
|
'display_username' => $this->display_username,
|
|
|
|
|
'display_avatar' => $this->display_avatar,
|
2026-03-29 22:24:28 +00:00
|
|
|
'social_account' => new SocialAccountResource($this->whenLoaded('socialAccount')),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|