🏡 index : ~doyle/koselig.git

author Jordan Doyle <jordan@doyle.wf> 2016-12-04 13:31:30.0 +00:00:00
committer Jordan Doyle <jordan@doyle.wf> 2016-12-04 13:31:30.0 +00:00:00
commit
39e91be7e579c2ba3dcced42697b7215bf9c97cd [patch]
tree
6898cb6083909e3b3c197c63cefebc5d65a1ae96
parent
70b77c1f2b9acf18210e4db72ad162bbf8f418c4
download
39e91be7e579c2ba3dcced42697b7215bf9c97cd.tar.gz

Add method to get a comment's avatar



Diff

 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