diff --git a/app/Http/Controllers/Oai/RequestController.php b/app/Http/Controllers/Oai/RequestController.php index e5b77aa..0162bec 100644 --- a/app/Http/Controllers/Oai/RequestController.php +++ b/app/Http/Controllers/Oai/RequestController.php @@ -149,7 +149,7 @@ class RequestController extends Controller $repositoryName = "Tethys RDR"; $repIdentifier = "tethys.geologie.ac.at"; $sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier(); - $earliestDateFromDb = optional(Dataset::earliestPublicationDate())->server_date_published; + $earliestDateFromDb = Dataset::earliestPublicationDate() != null ? Dataset::earliestPublicationDate()->server_date_published: null; // set parameters for oai-pmh.xslt $this->_proc->setParameter('', 'email', $email); diff --git a/app/Models/Dataset.php b/app/Models/Dataset.php index 3d741c5..238b1b8 100644 --- a/app/Models/Dataset.php +++ b/app/Models/Dataset.php @@ -258,17 +258,18 @@ class Dataset extends Model * * @return \Carbon\Carbon\Date */ - public function scopeEarliestPublicationDate($query, string $column = null) + public static function earliestPublicationDate(string $column = null) { if (!$column) { $column = self::PUBLISHED_AT; } - return $query->select('server_date_published') + $result = Dataset::select('server_date_published') ->where('server_date_published', '<>', null) ->where('server_state', 'published') ->orderBy('server_date_published', 'asc') ->first(); //->server_date_published; + return $result; } public function setServerState($targetType)