store-manage/app/Http/Resources/EmployeePromotionResource.php

40 lines
1.3 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class EmployeePromotionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'employee_id' => $this->employee_id,
'employee' => EmployeeResource::make($this->whenLoaded('employee')),
'store_id' => $this->store_id,
'store' => StoreResource::make($this->whenLoaded('store')),
'invitor_id' => $this->invitor_id,
'invitor' => EmployeeResource::make($this->whenLoaded('invitor')),
'job_id' => $this->job_id,
'job' => KeywordResource::make($this->whenLoaded('job')),
'promotion_status' => $this->promotion_status,
'promotion_status_text' => $this->promotion_status->text(),
'employee_data' => $this->employee_data,
'created_at' => $this->created_at->timestamp,
'created_format' => $this->created_at->format('Y-m-d H:i:s'),
'workflow_check' => WorkflowCheckResource::make($this->whenLoaded('workflow')),
];
}
}