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>
34 lines
795 B
PHP
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(),
|
|
];
|
|
}
|
|
}
|