common/services/traits/base/MultiSiteTrait.php
public function getSiteStats( $config = [] ) {

		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
		$limit	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;

		$modelClass	= static::$modelClass;
        $modelTable	= $modelClass::tableName();

        $query = new Query();

        $query->select( [ 'siteId', 'count(id) as total' ] )
			->from( $modelTable );

		// Filter Status
		if( isset( $status ) ) {

			$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
		}

		// Filter Type
		if( isset( $type ) ) {

			$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
		}

		// Limit
		if( $limit > 0 ) {

			$query->limit( $limit );
		}

		// Group and Order
		$query->groupBy( 'siteId' )->orderBy( 'total DESC' );

        return $query->all();
    }
public function getSiteStats( $config = [] ) {

		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
		$limit	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;

		$modelClass	= static::$modelClass;
        $modelTable	= $modelClass::tableName();

        $query = new Query();

        $query->select( [ 'siteId', 'count(id) as total' ] )
			->from( $modelTable );

		// Filter Status
		if( isset( $status ) ) {

			$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
		}

		// Filter Type
		if( isset( $type ) ) {

			$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
		}

		// Limit
		if( $limit > 0 ) {

			$query->limit( $limit );
		}

		// Group and Order
		$query->groupBy( 'siteId' )->orderBy( 'total DESC' );

        return $query->all();
    }
public function getSiteStats ( $ config = [ ] ) { $ status = isset ( $ config [ 'status' ] ) ? $ config [ 'status' ] : null ; $ type = isset ( $ config [ 'type' ] ) ? $ config [ 'type' ] : null ; $ limit = isset ( $ config [ 'limit' ] ) ? $ config [ 'limit' ] : 0 ; $ modelClass = static :: $ modelClass ; $ modelTable = $ modelClass :: tableName ( ) ; $ query = new Query ( ) ; $ query -> select ( [ 'siteId' , 'count(id) as total' ] ) -> from ( $ modelTable ) ; // Filter Status if ( isset ( $ status ) ) { $ query -> where ( "$modelTable.status=:status" , [ ':status' => $ status ] ) ; } // Filter Type if ( isset ( $ type ) ) { $ query -> andWhere ( "$modelTable.type=:type" , [ ':type' => $ type ] ) ; } // Limit if ( $ limit > 0 ) { $ query -> limit ( $ limit ) ; } // Group and Order $ query -> groupBy ( 'siteId' ) -> orderBy ( 'total DESC' ) ; return $ query -> all ( ) ; }
Returns model count of active models.

@param type $config
@return type
Returns model count of active models .