map(function($value){ if(is_array($value)){ return $this->indexValues($value ?? []); } return str_replace(array("\r", "\n"), '', strip_tags((string)$value)); }) ->values()->join(" ")." ". $this->_file?->originalName ?? "")); } public function toDB(): array { $searchIndex = $this->indexValues($this->data->toArray()); return [ "id" => $this->id, "status" => $this->status->value, "schema" => $this->schema, "_sys" => json_encode($this->_sys), "_file" => json_encode($this->_file), "data" => json_encode($this->data), "search" => $searchIndex, ]; } public static function fromDB(stdClass $data): Record { $file = json_decode($data->_file, true); if (!empty($file)) { $file = new FileData(...$file); } else { $file = null; } return new Record( id: $data->id, schema: $data->schema, status: Status::from($data->status), _sys: System::fromArray(json_decode($data->_sys, true)), data: new RecordData(json_decode($data->data, true)), _file: $file, ); } public function jsonSerialize(): static { return $this; } }