Files
landing-api/app/Http/Resources/RevisionResource.php
Josep Piguillem 5b46436641 Review, publish, preview and undo changes through the API
Revisions now call publishing only what publishes: a project's status is
whether the work is active, and a service is published by its flag.

The fake identity server answers by token, so a test can sign in a second
person.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 08:29:48 +02:00

34 lines
795 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Revision;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Revision
*/
class RevisionResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'event' => $this->event,
'author' => [
'id' => $this->user_id,
'name' => $this->resource->author(),
],
// Field => {old, new}. Translatable fields carry every language.
'changes' => (object) ($this->changeset ?? []),
'created_at' => $this->created_at?->toIso8601String(),
];
}
}