Display Uploaded Files

This commit is contained in:
R
2023-02-15 12:30:35 +07:00
parent 27523b8cce
commit 5d4033a9ca
13 changed files with 149 additions and 28 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace Modules\Internal\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
class ClaimRequestResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$filesGroupByType = $this->files->mapToGroups(function($file) {
return [$file->type => $file];
});
$data = [
'id' => $this->id,
'code' => $this->code,
'submission_date' => $this->submission_date,
'member' => $this->member,
'status' => $this->status ?? 'unknown',
'service_type' => $this->service_type,
'files_by_type' => $filesGroupByType
];
return $data;
}
}