public function avg($attr)
    {
        $builder = $this->_makeBuilderForAggregations(" avg($attr) ");
        return $this->_executeAndReturnFirst($builder, $this->_vals);
    }
public function avg($attr)
    {
        $builder = $this->_makeBuilderForAggregations(" avg($attr) ");
        return $this->_executeAndReturnFirst($builder, $this->_vals);
    }
public function avg ( $ attr ) { $ builder = $ this -> _makeBuilderForAggregations ( " avg($attr) " ) ; return $ this -> _executeAndReturnFirst ( $ builder , $ this -> _vals ) ; }
Return collection attribute average

Example:
echo Person::all()->avg("age");

@param string $attr attribute

@return mixed average
Return collection attribute average