better collection handlich in backend

This commit is contained in:
Arno Kaimbacher 2018-10-04 16:41:29 +02:00
parent 324eacf061
commit 50bcae442e
24 changed files with 623 additions and 68 deletions

View file

@ -7,9 +7,34 @@ use App\Models\Dataset;
class Collection extends Model
{
public $timestamps = false;
protected $fillable = [
'name',
'role_id',
];
public function documents()
{
return $this->belongsToMany(Dataset::class, 'link_documents_collections', 'collection_id', 'document_id');
}
#region self join
public function parent()
{
return $this->belongsTo(self::class, 'parent_id');
}
public function children()
{
return $this->hasMany(self::class, 'parent_id');
}
#endregion
/**
* Get the collection role that the dataset belongs to.
*/
public function collectionrole()
{
return $this->belongsTo(CollectionRole::class, 'role_id', 'id');
}
}