mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-28 03:33:37 +08:00
52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
<?php namespace BookStack\Actions;
|
|
|
|
use BookStack\Ownable;
|
|
|
|
/**
|
|
* @property string text
|
|
* @property string html
|
|
* @property int|null parent_id
|
|
* @property int local_id
|
|
*/
|
|
class Comment extends Ownable
|
|
{
|
|
protected $fillable = ['text', 'parent_id'];
|
|
protected $appends = ['created', 'updated'];
|
|
|
|
/**
|
|
* Get the entity that this comment belongs to
|
|
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
|
|
*/
|
|
public function entity()
|
|
{
|
|
return $this->morphTo('entity');
|
|
}
|
|
|
|
/**
|
|
* Check if a comment has been updated since creation.
|
|
* @return bool
|
|
*/
|
|
public function isUpdated()
|
|
{
|
|
return $this->updated_at->timestamp > $this->created_at->timestamp;
|
|
}
|
|
|
|
/**
|
|
* Get created date as a relative diff.
|
|
* @return mixed
|
|
*/
|
|
public function getCreatedAttribute()
|
|
{
|
|
return $this->created_at->diffForHumans();
|
|
}
|
|
|
|
/**
|
|
* Get updated date as a relative diff.
|
|
* @return mixed
|
|
*/
|
|
public function getUpdatedAttribute()
|
|
{
|
|
return $this->updated_at->diffForHumans();
|
|
}
|
|
}
|