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

35 lines
1.1 KiB
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TaskHygieneResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'month' => $this->month,
'store_id' => $this->store_id,
'store' => StoreResource::make($this->whenLoaded('store')),
'description' => $this->description,
'photos' => $this->photos,
'status' => $this->task_status,
'status_text' => $this->task_status->text(),
'created_at' => $this->created_at->timestamp,
'created_format' => $this->created_at->format('Y-m-d'),
'store_master_id' => $this->store_master_id,
'store_master' => EmployeeResource::make($this->whenLoaded('storeMaster')),
'workflow_check' => WorkflowCheckResource::make($this->whenLoaded('workflow')),
'task' => TaskResource::make($this->whenLoaded('task')),
];
}
}