*/ public function toArray(Request $request): array { $data = [ 'id' => $this->id, 'title' => $this->title, 'extension' => $this->extension, 'download_url' => Storage::url($this->pathname), 'size' => $this->size, 'created_by' => $this->createdBy ? new UserProfileResource($this->createdBy) : null, 'updated_by' => $this->updatedBy ? new UserProfileResource($this->updatedBy) : null, 'created_at' => (string) $this->created_at, 'updated_at' => (string) $this->updated_at, 'version' => $this->version, 'display_id'=>(string)$this->display_id, 'object_type'=>$this->object_type, 'object_id'=>$this->object_id, 'approval_status'=>$this->approval_status, 'naming_rule' => $this->namingRule ? new NamingRuleSimpleResource($this->namingRule) : null, 'naming_rules' => $this->naming_rules, 'doc_stage' => $this->doc_stage, 'doc_type' => $this->doc_type, 'bim_file' => $this->bimFile ? new BimFileResource($this->bimFile) : null, ]; if ($this->is_bim == 1 && $this->bimFile && $this->bimFile->convert_status == BimFileConvertStatus::DONE->value) { $data['model_preview'] = true; } return $data; } }