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

35 lines
941 B
PHP

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