 <p>Assuming you are having <code>Post-&gt;hasMany-&gt;Like</code> relationship and you have declared likes relationship as:</p> <pre><code>class Post{ public function likes(){ return $this-&gt;hasMany('Like'); } } </code></pre> <p>create a new function say <code>likeCountRelation</code> as:</p> <pre><code>public function likeCountRelation() { $a = $this-&gt;likes(); return $a-&gt;selectRaw($a-&gt;getForeignKey() . ', count(*) as count')-&gt;groupBy($a-&gt;getForeignKey()); } </code></pre> <p>now you can override <code>__get()</code> function as:</p> <pre><code>public function __get($attribute) { if (array_key_exists($attribute, $this-&gt;attributes)) { return $this-&gt;attributes[$attribute]; } switch ($attribute) { case 'likesCount': return $this-&gt;attributes[$attribute] = $this-&gt;likesCountRelation-&gt;first() ? $this-&gt;likesCountRelation-&gt;first()-&gt;count : 0; break; default: return parent::__get($attribute); } } </code></pre> <p>or you can use getattribute function as :</p> <pre><code>public function getLikesCountAttribute(){ return $this-&gt;likesCountRelation-&gt;first() ? $this-&gt;likesCountRelation-&gt;first()-&gt;count : 0; } </code></pre> <p>and simply access likesCount as <code>$post-&gt;likesCount</code> you can even eager load it like:</p> <pre><code>$posts=Post::with('likesCountRelation')-&gt;get(); foreach($post as $post){ $post-&gt;likesCount; } </code></pre> <p><code>NOTE:</code> Same logic can be used for morph many relationships.</p>