more metadata fields

This commit is contained in:
Arno Kaimbacher 2019-01-22 18:24:18 +01:00
parent b74927b5f2
commit bba029e74e
14 changed files with 288 additions and 100 deletions

View file

@ -6,7 +6,8 @@ use App\Library\Xml\DatasetExtension;
use App\Models\Collection;
use App\Models\License;
use App\Models\Project;
use App\Models\Title;
use App\Models\Description;
use App\Models\Titel;
use App\Models\Person;
use App\Models\XmlCache;
use App\Models\File;
@ -129,33 +130,28 @@ class Dataset extends Model
#endregion
#region title table:
public function titlesAbstracts()
{
return $this->hasMany(Title::class, 'document_id', 'id');
}
public function titles()
{
return $this->hasMany(Title::class, 'document_id', 'id')
->where('type', 'main');
return $this->hasMany(Titel::class, 'document_id', 'id');
}
public function addMainTitle(Title $title)
{
$title->type = 'main';
$this->titlesAbstracts()->save($title);
$this->titles()->save($title);
// $this->titles()->save($title, ['type' => 'main']);
}
/**
* Relation abstracts
*
* @return \App\Title
* @return \App\Description
*/
public function abstracts()
{
return $this->hasMany(Title::class, 'document_id', 'id')
->where('type', 'abstract');
return $this->hasMany(Description::class, 'document_id', 'id');
}
public function addMainAbstract(Title $title)
{
$title->type = 'abstract';

View file

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

View file

@ -6,7 +6,7 @@ use App\Models\Dataset;
class Title extends Model
{
protected $table = 'document_title_abstracts';
protected $table = 'dataset_titles';
public $timestamps = false;