$this->id, 'reference' => $this->reference, 'status' => (int)$this->status, 'document_type' => $this->document_type, 'owner' => new CompanyResource($this->whenLoaded('owner')), 'files' => $this->when($this->shouldIncludeFiles(false), FileResource::collection($this->files)), 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') ]; } /** * include only when should include file, to be loaded if needed in the UI * @param bool $includeFile * @return bool */ private function shouldIncludeFiles(bool $includeFile): bool { return $includeFile; } }