From 39e91be7e579c2ba3dcced42697b7215bf9c97cd Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 4 Dec 2016 13:31:30 +0000 Subject: [PATCH] Add method to get a comment's avatar --- src/Models/Comment.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Models/Comment.php b/src/Models/Comment.php index 3fd5210..78bd692 100644 --- a/src/Models/Comment.php +++ b/src/Models/Comment.php @@ -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 -- libgit2 1.7.2