tethys/app/Models/Collection.php
Arno Kaimbacher 8ea540a88c - laravel framework upgrade frpm 7.x to 8. see also: https://laravel.com/docs/8.x/upgrade#assert-exact-json-method
- use  PHP7 null coalesce operator instead of laravel optional method
- change Breadcrumbs::register method to Bredcrumbs::for method
- composer updates
2022-08-10 11:18:10 +02:00

46 lines
946 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Dataset;
class Collection extends Model
{
use HasFactory;
public $timestamps = false;
//mass assignable
protected $fillable = [
'name',
'number',
'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');
}
}