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.
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class DataTable extends Model
|
|
|
|
{
|
|
|
|
/** Owning user */
|
|
|
|
public function owner()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class, 'owner_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Fork precursor */
|
|
|
|
public function precursor()
|
|
|
|
{
|
|
|
|
return $this->belongsTo(DataTable::class, 'precursor_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Fork descendants */
|
|
|
|
public function descendants()
|
|
|
|
{
|
|
|
|
return $this->hasMany(DataTable::class, 'precursor_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Changesets */
|
|
|
|
public function changesets()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Changeset::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Data rows */
|
|
|
|
public function dataRows()
|
|
|
|
{
|
|
|
|
return $this->hasMany(DataRow::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Changesets already merged */
|
|
|
|
public function appliedChangesets()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Changeset::class)->where('applied', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Changesets already merged */
|
|
|
|
public function pendingChangesets()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Changeset::class)->where('applied', false);
|
|
|
|
}
|
|
|
|
}
|