3 namespace BookStack\Actions;
6 use BookStack\Traits\HasCreatorAndUpdater;
7 use Illuminate\Database\Eloquent\Factories\HasFactory;
8 use Illuminate\Database\Eloquent\Relations\MorphTo;
12 * @property string $text
13 * @property string $html
14 * @property int|null $parent_id
15 * @property int $local_id
17 class Comment extends Model
20 use HasCreatorAndUpdater;
22 protected $fillable = ['text', 'parent_id'];
23 protected $appends = ['created', 'updated'];
26 * Get the entity that this comment belongs to.
28 public function entity(): MorphTo
30 return $this->morphTo('entity');
34 * Check if a comment has been updated since creation.
36 public function isUpdated(): bool
38 return $this->updated_at->timestamp > $this->created_at->timestamp;
42 * Get created date as a relative diff.
46 public function getCreatedAttribute()
48 return $this->created_at->diffForHumans();
52 * Get updated date as a relative diff.
56 public function getUpdatedAttribute()
58 return $this->updated_at->diffForHumans();