|
|
|
<?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);
|
|
|
|
}
|
|
|
|
}
|