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.
 
 
 
 
 
 
datatable.directory/app/Models/DataTable.php

72 lines
1.5 KiB

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* A data table object (referencing changesets and rows)
*/
class DataTable extends Model
{
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
/** Owning user */
public function owner()
{
return $this->belongsTo(User::class, 'owner_id');
}
/** Fork precursor */
public function parentTable()
{
return $this->belongsTo(DataTable::class, 'parent_table_id');
}
/** Fork descendants */
public function forks()
{
return $this->hasMany(DataTable::class, 'parent_table_id');
}
/** Changesets */
public function changesets()
{
return $this->hasMany(Changeset::class);
}
/** Data rows */
public function dataRows()
{
return $this->hasMany(DataRow::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');
}
/** Reports of this table */
public function reportsOf()
{
return $this->morphMany(ContentReport::class, 'object');
}
}