tethys/app/Models/Collection.php

41 lines
830 B
PHP
Raw Normal View History

2018-09-10 13:09:10 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
class Collection extends Model
{
2018-10-04 14:41:29 +00:00
public $timestamps = false;
protected $fillable = [
'name',
'role_id',
];
2018-09-10 13:09:10 +00:00
public function documents()
{
return $this->belongsToMany(Dataset::class, 'link_documents_collections', 'collection_id', 'document_id');
}
2018-10-04 14:41:29 +00:00
#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');
}
2018-09-10 13:09:10 +00:00
}