parent
c75b25b89b
commit
6fd1d7eb89
@ -1,51 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
/** |
||||
* A patch describing changes to apply or applied to a data table. |
||||
*/ |
||||
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'); |
||||
} |
||||
|
||||
/** Reports of this changeset */ |
||||
public function reportsOf() |
||||
{ |
||||
return $this->morphMany(ContentReport::class, 'object'); |
||||
} |
||||
|
||||
/** |
||||
* Scope for pending changesets |
||||
* |
||||
* @param \Illuminate\Database\Eloquent\Builder $query |
||||
* @return \Illuminate\Database\Eloquent\Builder |
||||
*/ |
||||
public function scopePending($query) |
||||
{ |
||||
return $query->where('applied', false); |
||||
} |
||||
|
||||
/** |
||||
* Scope for applied changesets |
||||
* |
||||
* @param \Illuminate\Database\Eloquent\Builder $query |
||||
* @return \Illuminate\Database\Eloquent\Builder |
||||
*/ |
||||
public function scopeApplied($query) |
||||
{ |
||||
return $query->where('applied', true); |
||||
} |
||||
} |
@ -1,17 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
/** |
||||
* Row in a data table |
||||
*/ |
||||
class DataRow extends Model |
||||
{ |
||||
/** Parent data table */ |
||||
public function dataTable() |
||||
{ |
||||
return $this->belongsTo(DataTable::class); |
||||
} |
||||
} |
@ -0,0 +1,41 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
/** |
||||
* Change proposal |
||||
*/ |
||||
class Proposal extends Model |
||||
{ |
||||
/** Added rows */ |
||||
public function addedRows() |
||||
{ |
||||
return $this->belongsToMany(Row::class, 'proposal_add_row_pivot'); |
||||
} |
||||
|
||||
/** Removed rows */ |
||||
public function removedRows() |
||||
{ |
||||
return $this->belongsToMany(Row::class, 'proposal_remove_row_pivot'); |
||||
} |
||||
|
||||
/** Authoring user */ |
||||
public function author() |
||||
{ |
||||
return $this->belongsTo(User::class, 'author_id'); |
||||
} |
||||
|
||||
/** Target revision */ |
||||
public function revision() |
||||
{ |
||||
return $this->belongsTo(Revision::class); |
||||
} |
||||
|
||||
/** Target table (that this was submitted to) */ |
||||
public function table() |
||||
{ |
||||
return $this->belongsTo(Table::class); |
||||
} |
||||
} |
@ -0,0 +1,44 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
use Riesjart\Relaquent\Model\Concerns\HasRelaquentRelationships; |
||||
|
||||
/** |
||||
* Table revision (a set of rows) |
||||
*/ |
||||
class Revision extends Model |
||||
{ |
||||
use HasRelaquentRelationships; |
||||
|
||||
/** Included rows */ |
||||
public function rows() |
||||
{ |
||||
return $this->belongsToMany(Row::class, 'revision_row_pivot'); |
||||
} |
||||
|
||||
/** Proposal that lead to this revision */ |
||||
public function appliedProposal() |
||||
{ |
||||
return $this->hasOneThrough(Proposal::class, 'revision_proposal_pivot'); |
||||
} |
||||
|
||||
/** Proposals that depend on this revision */ |
||||
public function dependentProposals() |
||||
{ |
||||
return $this->hasMany(Proposal::class); |
||||
} |
||||
|
||||
/** Revision this orignates from */ |
||||
public function parentRevision() |
||||
{ |
||||
return $this->belongsTo(Revision::class, 'ancestor_id'); |
||||
} |
||||
|
||||
/** Tables referencing this revision */ |
||||
public function tables() |
||||
{ |
||||
return $this->belongsToMany(Table::class, 'table_revision_pivot'); |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
<?php |
||||
|
||||
namespace App\Models; |
||||
|
||||
use Illuminate\Database\Eloquent\Model; |
||||
|
||||
/** |
||||
* Row in a data table |
||||
*/ |
||||
class Row extends Model |
||||
{ |
||||
} |
@ -0,0 +1,37 @@ |
||||
<?php |
||||
|
||||
use Illuminate\Support\Facades\Schema; |
||||
use Illuminate\Database\Schema\Blueprint; |
||||
use Illuminate\Database\Migrations\Migration; |
||||
|
||||
class CreateRevisionProposalPivotTable extends Migration |
||||
{ |
||||
/** |
||||
* Run the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function up() |
||||
{ |
||||
Schema::create('revision_proposal_pivot', function (Blueprint $table) { |
||||
$table->unsignedInteger('proposal_id')->index(); |
||||
$table->unsignedInteger('revision_id')->index(); |
||||
|
||||
$table->foreign('proposal_id')->references('id')->on('proposals') |
||||
->onDelete('cascade'); |
||||
|
||||
$table->foreign('revision_id')->references('id')->on('revisions') |
||||
->onDelete('cascade'); |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* Reverse the migrations. |
||||
* |
||||
* @return void |
||||
*/ |
||||
public function down() |
||||
{ |
||||
Schema::dropIfExists('revision_proposal_pivot'); |
||||
} |
||||
} |
Loading…
Reference in new issue