New-Thanasoft/thanasoft-back/app/Http/Resources/Intervention/InterventionAttachmentResource.php
2025-11-11 17:45:58 +03:00

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')
];
}
}