updated models
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* A data table object (referencing changesets and rows)
|
||||
*/
|
||||
class Table extends Model
|
||||
{
|
||||
/** Owning user */
|
||||
public function owner()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
/** Fork precursor */
|
||||
public function parentTable()
|
||||
{
|
||||
return $this->belongsTo(Table::class, 'ancestor_id');
|
||||
}
|
||||
|
||||
/** Fork descendants */
|
||||
public function forks()
|
||||
{
|
||||
return $this->hasMany(Table::class, 'ancestor_id');
|
||||
}
|
||||
|
||||
/** All related revisions (this may include merged revisions) */
|
||||
public function revisions()
|
||||
{
|
||||
return $this->belongsToMany(Revision::class, 'table_revision_pivot');
|
||||
}
|
||||
|
||||
/** Active revision */
|
||||
public function activeRevision()
|
||||
{
|
||||
return $this->hasOne(Revision::class, 'revision_id');
|
||||
}
|
||||
|
||||
/** Proposals submitted to this table */
|
||||
public function proposals()
|
||||
{
|
||||
return $this->hasMany(Proposal::class);
|
||||
}
|
||||
|
||||
/** User-submitted comments */
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(TableComment::class);
|
||||
}
|
||||
|
||||
/** Users favouriting this table */
|
||||
public function favouritingUsers()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'table_favourites');
|
||||
}
|
||||
|
||||
/** Users to notify about comments */
|
||||
public function discussionFollowers()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'discussion_follows');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user