3 namespace BookStack\Actions;
6 use BookStack\Traits\HasCreatorAndUpdater;
7 use Illuminate\Database\Eloquent\Relations\MorphTo;
10 * @property string text
11 * @property string html
12 * @property int|null parent_id
13 * @property int local_id
15 class Comment extends Model
17 use HasCreatorAndUpdater;
19 protected $fillable = ['text', 'parent_id'];
20 protected $appends = ['created', 'updated'];
23 * Get the entity that this comment belongs to.
25 public function entity(): MorphTo
27 return $this->morphTo('entity');
31 * Check if a comment has been updated since creation.
33 public function isUpdated(): bool
35 return $this->updated_at->timestamp > $this->created_at->timestamp;
39 * Get created date as a relative diff.
43 public function getCreatedAttribute()
45 return $this->created_at->diffForHumans();
49 * Get updated date as a relative diff.
53 public function getUpdatedAttribute()
55 return $this->updated_at->diffForHumans();