add keywords during publishing

This commit is contained in:
Arno Kaimbacher 2019-03-18 14:32:29 +01:00
parent f3f17d9371
commit d9b26afb3f
13 changed files with 332 additions and 96 deletions

View file

@ -194,6 +194,11 @@ class Dataset extends Model
return $this->hasMany(\App\Models\DatasetReference::class, 'document_id', 'id');
}
public function subjects()
{
return $this->hasMany(\App\Models\Subject::class, 'document_id', 'id');
}
/**
* Get the xml-cache record associated with the dataset.

19
app/Models/Subject.php Normal file
View file

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class Subject extends Model
{
protected $table = 'document_subjects';
public $timestamps = false;
protected $fillable = ['value', 'type'];
public function dataset()
{
return $this->belongsTo(Dataset::class, 'document_id', 'id');
}
}

View file

@ -14,7 +14,7 @@ class XmlCache extends Model
* @var string
*/
protected $table = 'document_xml_cache';
public $timestamps = false;
public $timestamps = false;
/**
@ -56,14 +56,13 @@ class XmlCache extends Model
}
/**
* Check if a document in a specific xml version is already cached or not.
* Check if a dataset 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)
public function hasValidEntry($datasetId, $serverDateModified) : bool
{
$select = DB::table('document_xml_cache');
$select->where('document_id', '=', $datasetId)