27 lines
864 B
PHP
27 lines
864 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class EventResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->client_id,
|
|
'title' => $this->title,
|
|
'date' => $this->date->format('Y-m-d'),
|
|
'emotion' => (float) $this->emotion,
|
|
'customColor' => $this->custom_color,
|
|
'gradientPreset' => $this->gradient_preset,
|
|
'image' => $this->image,
|
|
'note' => $this->note ?? '',
|
|
'media' => EventMediaResource::collection($this->whenLoaded('media')),
|
|
'syncStatus' => 'synced',
|
|
'createdAt' => $this->created_at->getTimestampMs(),
|
|
'updatedAt' => $this->updated_at->getTimestampMs(),
|
|
];
|
|
}
|
|
}
|