add models and relations
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Comment on a data table
|
||||
*/
|
||||
class TableComment extends Model
|
||||
{
|
||||
/** Context data table */
|
||||
public function dataTable()
|
||||
{
|
||||
return $this->belongsTo(DataTable::class);
|
||||
}
|
||||
|
||||
/** Parent comment (that we reply to; can be null) */
|
||||
public function ancestor()
|
||||
{
|
||||
return $this->belongsTo(TableComment::class, 'ancestor_id');
|
||||
}
|
||||
|
||||
/** Replies to this comment */
|
||||
public function replies()
|
||||
{
|
||||
return $this->hasMany(TableComment::class, 'ancestor_id');
|
||||
}
|
||||
|
||||
/** Authoring user */
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'author_id');
|
||||
}
|
||||
|
||||
/** Reports of this comment */
|
||||
public function reportsOf()
|
||||
{
|
||||
return $this->morphMany(ContentReport::class, 'object');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user