22 lines
676 B
PHP
22 lines
676 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ArtworkResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'title' => $this->title,
|
|
'description' => $this->description,
|
|
'isPublic' => $this->is_public,
|
|
'publishedOn' => $this->publication_date ? $this->publication_date->toIso8601String() : null,
|
|
'owner' => new UserResource($this->whenLoaded('owner')), // Charge la ressource User si l'owner est chargé
|
|
];
|
|
}
|
|
}
|