request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; $user = User::findOne($user_id); if(empty( $user )) { throw new NotFoundHttpException('User not found'); } if(!empty( $specialization_id )) { $specializations[] = $specialization_id; $specialization = Specialization::find() ->where([ 'specialization_id' => $specialization_id ]) ->one(); if(!empty( $specialization )) { $specializations = $specialization->stack; } else { $specializations = NULL; } } else { $specializations = NULL; } $portfolios = $user->getPortfolios() ->asArray() ->joinWith('specializations') ->andWhere([ 'not', [ 'portfolio.lat' => NULL ], ]) ->andWhere([ 'not', [ 'portfolio.lng' => NULL ], ]) ->andWhere([ '>=', 'portfolio.date_add', date('Y-m-d', $start), ]) ->andFilterWhere([ 'specialization.specialization_id' => $specializations ]) ->all(); return [ 'result' => $portfolios ]; } public function actionPortfolioAll() { $request = \Yii::$app->request; $response = \Yii::$app->response; $response->format = $response::FORMAT_JSON; $portfolios = Portfolio::find() ->asArray() ->andWhere([ 'not', [ 'portfolio.lat' => NULL ], ]) ->andWhere([ 'not', [ 'portfolio.lng' => NULL ], ]) ->all(); return [ 'result' => $portfolios ]; } }