where( [ 'gallery' => true, ] ) ->with( [ 'lang' => function (ActiveQuery $query) { $query->andWhere( [ 'language_id' => Language::getCurrent()->id, ] ); }, ] ) ->all(); } /** * @param array $images */ public function saveImages($images) { \Yii::$app->db->createCommand() ->update( 'ImageManager', [ 'gallery' => false, ], '1 = 1' ) ->execute(); if (!empty($images)) { $condition = 'id IN (' . implode(',', $images) . ')'; \Yii::$app->db->createCommand() ->update( 'ImageManager', [ 'gallery' => true, ], $condition ) ->execute(); } } }