datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.4 KiB
66 lines
1.4 KiB
6 years ago
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
6 years ago
|
/**
|
||
|
* A data table object (referencing changesets and rows)
|
||
|
*/
|
||
6 years ago
|
class Table extends Model
|
||
6 years ago
|
{
|
||
6 years ago
|
/** Owning user */
|
||
|
public function owner()
|
||
|
{
|
||
|
return $this->belongsTo(User::class, 'owner_id');
|
||
|
}
|
||
|
|
||
|
/** Fork precursor */
|
||
6 years ago
|
public function parentTable()
|
||
6 years ago
|
{
|
||
6 years ago
|
return $this->belongsTo(Table::class, 'ancestor_id');
|
||
6 years ago
|
}
|
||
|
|
||
|
/** Fork descendants */
|
||
6 years ago
|
public function forks()
|
||
6 years ago
|
{
|
||
6 years ago
|
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');
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
/** Active revision */
|
||
|
public function activeRevision()
|
||
6 years ago
|
{
|
||
6 years ago
|
return $this->hasOne(Revision::class, 'revision_id');
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
/** Proposals submitted to this table */
|
||
|
public function proposals()
|
||
6 years ago
|
{
|
||
6 years ago
|
return $this->hasMany(Proposal::class);
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
/** 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()
|
||
6 years ago
|
{
|
||
6 years ago
|
return $this->belongsToMany(User::class, 'discussion_follows');
|
||
6 years ago
|
}
|
||
6 years ago
|
}
|