title: Use accesor getAttribute in query model Laravel
body: <p>I have model Post, and I have:</p>
  
  <pre><code>protected $appends = ['reviews_count'];
  
  public static function boot()
  {
      parent::boot();
  
      static::saved(function () {
          static::updateRanks();
      });
  }
  
  public function reviews() {
     return $this-&gt;hasMany(Review:class);
  }
  
  public static function updateRanks()
  {
      DB::statement("UPDATE posts set `rank` = (SELECT FIND_IN_SET( CONCAT(points, '_', created_at), (SELECT GROUP_CONCAT( CONCAT(points, '_', created_at) ORDER BY points desc, created_at asc ) FROM (select * from posts) as posts_rankings)))");
  }
  
  public function getReviewsCountAttribute()
  {
      return $this-&gt;reviews()-&gt;active()-&gt;count();
  }
  </code></pre>
  
  <p>I need in <code>CONCAT(points, '_', created_at)</code> add a <code>reviews_count</code> and next do <code>ORDER BY points desc, reviews_count desc, created_at asc</code>. How I can do this? If I add, I get error: <code>unknown column reviews_count..</code>.</p>