datatable.directory codebase https://datatable.directory/
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.
datatable.directory/app/Models/TableComment.php

61 lines
1.3 KiB

<?php
namespace App\Models;
use App\Models\Concerns\Reportable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Comment on a data table
*
* @property int $id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property int $table_id
* @property int $author_id
* @property int $ancestor_id
* @property string $message
* @property User $author
* @property Table $table
* @property TableComment|null $ancestor
* @property TableComment[]|Collection $replies
*/
class TableComment extends Model
{
use Reportable;
protected static function boot()
{
parent::boot();
static::deleting(function(TableComment $self) {
$self->reportsOf()->delete();
});
}
/** Context data table */
7 years ago
public function table()
{
7 years ago
return $this->belongsTo(Table::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');
}
}