src/League/Monga/Collection.php
public function aggregate($aggregation = [])
    {
        if ($aggregation instanceof Closure) {
            // Store the callback
            $callback = $aggregation;

            // Create a new pipeline
            $aggregation = new Query\Aggregation();

            // Fire the callback
            $callback($aggregation);
        }

        if ($aggregation instanceof Query\Aggregation) {
            // Retrieve the pipeline
            $aggregation = $aggregation->getPipeline();
        }

        // Execute the aggregation.
        return $this->collection->aggregate($aggregation);
    }
public function aggregate($aggregation = [])
    {
        if ($aggregation instanceof Closure) {
            // Store the callback
            $callback = $aggregation;

            // Create a new pipeline
            $aggregation = new Query\Aggregation();

            // Fire the callback
            $callback($aggregation);
        }

        if ($aggregation instanceof Query\Aggregation) {
            // Retrieve the pipeline
            $aggregation = $aggregation->getPipeline();
        }

        // Execute the aggregation.
        return $this->collection->aggregate($aggregation);
    }
public function aggregate ( $ aggregation = [ ] ) { if ( $ aggregation instanceof Closure ) { // Store the callback $ callback = $ aggregation ; // Create a new pipeline $ aggregation = new Query \ Aggregation ( ) ; // Fire the callback $ callback ( $ aggregation ) ; } if ( $ aggregation instanceof Query \ Aggregation ) { // Retrieve the pipeline $ aggregation = $ aggregation -> getPipeline ( ) ; } // Execute the aggregation. return $ this -> collection -> aggregate ( $ aggregation ) ; }
Aggregate a collection

@param mixed $aggregation aggregaction pipeline of callback Closure

@return array aggregation result
Aggregate a collection