better collection handlich in backend
This commit is contained in:
parent
324eacf061
commit
50bcae442e
24 changed files with 623 additions and 68 deletions
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue