Add method to get a comment's avatar
Diff
src/Models/Comment.php | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
use Koselig\Support\Action;
use Koselig\Support\Wordpress;
use Watson\Rememberable\Rememberable;
use WP_Comment;
/**
* Table containing all the comments belonging to posts.
@@ -115,6 +116,28 @@ class Comment extends Model
}
/**
* Get an avatar for the comment.
*
* @param array $args args to pass to {@link get_avatar_url}
* @return false|string
*/
public function avatar($args = [])
{
return get_avatar_url($this->toWordpressComment(), $args);
}
/**
* Get the {@link WP_Comment} instance for this Comment.
*
* @deprecated Use the methods already provided by this model.
* @return WP_Comment
*/
public function toWordpressComment()
{
return new WP_Comment((object) $this->toArray());
}
/**
* Get the comment this comment belongs to.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo