belongsTo(Dataset::class, 'document_id', 'id'); } /** * Get dom document of 'xml_data' string * * @return \DOMDocument */ public function getDomDocument() { $dom = new \DOMDocument('1.0', 'utf-8'); $xmlData = $this->xml_data; $dom->loadXML($xmlData); return $dom; } /** * Check if a document in a specific xml version is already cached or not. * * @param mixed $datasetId * @param mixed $xmlVersion * @param mixed $serverDateModified * @return bool Returns true on cached hit else false. */ public function hasValidEntry($datasetId, $serverDateModified) { $select = DB::table('document_xml_cache'); $select->where('document_id', '=', $datasetId) ->where('server_date_modified', '=', $serverDateModified); $row = $select->first(); if (null === $row) { return false; } else { return true; } } }