original_string: public function scopeMostVisited(Builder $query, $limit = null)
      {
          $query->select(\DB::raw('nodes.*, count(*) as `aggregate`'))
              ->join('node_site_view', 'nodes.id', '=', 'node_site_view.node_id')
              ->groupBy('nodes.id')
              ->orderBy('aggregate', 'desc');
  
          if ($limit)
          {
              $query->limit($limit);
          }
  
          return $query;
      }
code: public function scopeMostVisited(Builder $query, $limit = null)
      {
          $query->select(\DB::raw('nodes.*, count(*) as `aggregate`'))
              ->join('node_site_view', 'nodes.id', '=', 'node_site_view.node_id')
              ->groupBy('nodes.id')
              ->orderBy('aggregate', 'desc');
  
          if ($limit)
          {
              $query->limit($limit);
          }
  
          return $query;
      }
code_tokens: public function scopeMostVisited ( Builder $ query , $ limit = null ) { $ query -> select ( \ DB :: raw ( 'nodes.*, count(*) as `aggregate`' ) ) -> join ( 'node_site_view' , 'nodes.id' , '=' , 'node_site_view.node_id' ) -> groupBy ( 'nodes.id' ) -> orderBy ( 'aggregate' , 'desc' ) ; if ( $ limit ) { $ query -> limit ( $ limit ) ; } return $ query ; }
docstring: Most visited scope
  
  @param Builder $query
  @param int|null $limit
  @return Builder
docstring_tokens: Most visited scope