reworked migrations AGAIN and added relations to models
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Changeset extends Model
|
||||
{
|
||||
/** Parent data table */
|
||||
public function dataTable()
|
||||
{
|
||||
return $this->belongsTo(DataTable::class);
|
||||
}
|
||||
|
||||
/** Author who created it user */
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'author_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DataRow extends Model
|
||||
{
|
||||
/** Parent data table */
|
||||
public function dataTable()
|
||||
{
|
||||
return $this->belongsTo(DataTable::class);
|
||||
}
|
||||
}
|
||||
@@ -6,5 +6,45 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class DiscussionFollow extends Pivot
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TableComment extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class TableFavourite extends Pivot
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TableRevision extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use AdamWathan\EloquentOAuth\OAuthIdentity;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
@@ -26,4 +27,22 @@ class User extends Authenticatable
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/** Owned tables */
|
||||
public function dataTables()
|
||||
{
|
||||
return $this->hasMany(DataTable::class);
|
||||
}
|
||||
|
||||
/** Assigned OAuth identities */
|
||||
public function socialIdentities()
|
||||
{
|
||||
return $this->hasMany(OAuthIdentity::class);
|
||||
}
|
||||
|
||||
/** Assigned OAuth identities */
|
||||
public function changesets()
|
||||
{
|
||||
return $this->hasMany(Changeset::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class UserFollow extends Pivot
|
||||
{
|
||||
//
|
||||
}
|
||||
Reference in New Issue
Block a user