45 lines
1.6 KiB
PHP
Executable File
45 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Internal\Transformers;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Str;
|
|
use App\Models\Organization;
|
|
|
|
class RequestLogResource 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 [Str::slug($file->type, '_') => $file];
|
|
});
|
|
$provider = Organization::where('id', $this->organization_id)->first();
|
|
|
|
$data = [
|
|
'id' => $this->id,
|
|
'code' => $this->code,
|
|
'submission_date' => $this->created_at, // submsion_date diambil dari kolom created_at
|
|
'admission_date' => $this->submission_date, // admission_date diambil dari kolom submission
|
|
'submission_date_fgl' => $this->approved_final_log_at,
|
|
'member_name' => $this->member->name,
|
|
'status' => $this->status ?? 'unknown',
|
|
'provider' => $provider ? $provider->name : '-',
|
|
'status_final_log' => $this->status_final_log ?? 'unknown',
|
|
'nominal' => $this->nominal ?? 'unknown',
|
|
'status_approval' => $this->status_approval ?? 'requested',
|
|
'service_name' => $this->service ? $this->service->name : '',
|
|
'payment_type' => $this->payment_type,
|
|
'payment_type_name' => $this->payment_type_name,
|
|
'files_by_type' => $filesGroupByType
|
|
];
|
|
|
|
return $data;
|
|
}
|
|
}
|