common/services/traits/mappers/CategoryTrait.php
public function getPinnedByCategoryId( $categoryId, $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$config[ 'page' ]	= isset( $config[ 'page' ] ) ? $config[ 'page' ] : false;
		$config[ 'query' ]	= isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find();
		$config[ 'limit' ]	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10;
		$config[ 'active' ]	= isset( $config[ 'active' ] ) ? $config[ 'active' ] : true;

		if( $config[ 'active' ] ) {

			$config[ 'query' ]->joinWith( 'activeCategories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}
		else {

			$config[ 'query' ]->joinWith( 'categories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}

		if( $config[ 'page' ] ) {

			$page	= $this->getPublicPage( $config );

			return $page->getModels();
		}

		return $config[ 'query' ]->limit( $config[ 'limit' ] )->all();
	}
public function getPinnedByCategoryId( $categoryId, $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$config[ 'page' ]	= isset( $config[ 'page' ] ) ? $config[ 'page' ] : false;
		$config[ 'query' ]	= isset( $config[ 'query' ] ) ? $config[ 'query' ] : $modelClass::find();
		$config[ 'limit' ]	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10;
		$config[ 'active' ]	= isset( $config[ 'active' ] ) ? $config[ 'active' ] : true;

		if( $config[ 'active' ] ) {

			$config[ 'query' ]->joinWith( 'activeCategories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}
		else {

			$config[ 'query' ]->joinWith( 'categories' )->andWhere( [ 'modelId' => $categoryId, "$modelTable.pinned" => true ] );
		}

		if( $config[ 'page' ] ) {

			$page	= $this->getPublicPage( $config );

			return $page->getModels();
		}

		return $config[ 'query' ]->limit( $config[ 'limit' ] )->all();
	}
public function getPinnedByCategoryId ( $ categoryId , $ config = [ ] ) { $ modelClass = static :: $ modelClass ; $ modelTable = $ this -> getModelTable ( ) ; $ config [ 'page' ] = isset ( $ config [ 'page' ] ) ? $ config [ 'page' ] : false ; $ config [ 'query' ] = isset ( $ config [ 'query' ] ) ? $ config [ 'query' ] : $ modelClass :: find ( ) ; $ config [ 'limit' ] = isset ( $ config [ 'limit' ] ) ? $ config [ 'limit' ] : 10 ; $ config [ 'active' ] = isset ( $ config [ 'active' ] ) ? $ config [ 'active' ] : true ; if ( $ config [ 'active' ] ) { $ config [ 'query' ] -> joinWith ( 'activeCategories' ) -> andWhere ( [ 'modelId' => $ categoryId , "$modelTable.pinned" => true ] ) ; } else { $ config [ 'query' ] -> joinWith ( 'categories' ) -> andWhere ( [ 'modelId' => $ categoryId , "$modelTable.pinned" => true ] ) ; } if ( $ config [ 'page' ] ) { $ page = $ this -> getPublicPage ( $ config ) ; return $ page -> getModels ( ) ; } return $ config [ 'query' ] -> limit ( $ config [ 'limit' ] ) -> all ( ) ; }
Works only with models having pinned column
Works only with models having pinned column