3 namespace BookStack\Actions;
6 use BookStack\Traits\HasCreatorAndUpdater;
7 use Illuminate\Database\Eloquent\Relations\MorphTo;
11 * @property string $text
12 * @property string $html
13 * @property int|null $parent_id
14 * @property int $local_id
16 class Comment extends Model
18 use HasCreatorAndUpdater;
20 protected $fillable = ['text', 'parent_id'];
21 protected $appends = ['created', 'updated'];
24 * Get the entity that this comment belongs to.
26 public function entity(): MorphTo
28 return $this->morphTo('entity');
32 * Check if a comment has been updated since creation.
34 public function isUpdated(): bool
36 return $this->updated_at->timestamp > $this->created_at->timestamp;
40 * Get created date as a relative diff.
44 public function getCreatedAttribute()
46 return $this->created_at->diffForHumans();
50 * Get updated date as a relative diff.
54 public function getUpdatedAttribute()
56 return $this->updated_at->diffForHumans();