34 lines
955 B
PHP
34 lines
955 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources\Intervention;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class InterventionAttachmentResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'intervention_id' => $this->intervention_id,
|
|
'file' => $this->whenLoaded('file', function () {
|
|
return [
|
|
'id' => $this->file->id,
|
|
'name' => $this->file->name,
|
|
'path' => $this->file->path,
|
|
'mime_type' => $this->file->mime_type,
|
|
'size' => $this->file->size
|
|
];
|
|
}),
|
|
'label' => $this->label,
|
|
'created_at' => $this->created_at->format('Y-m-d H:i:s')
|
|
];
|
|
}
|
|
}
|