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

28 lines
789 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class TaskLedgerResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->resource->id,
'date' => $this->resource->date,
'store' => StoreResource::make($this->whenLoaded('store')),
'status' => $this->resource->task_status,
'created_at' => $this->resource->created_at->timestamp,
'store_master_id' => $this->store_master_id,
'store_master' => EmployeeResource::make($this->whenLoaded('storeMaster')),
];
}
}