コード例 #1
0
ファイル: SiteController.php プロジェクト: baitur/rocket_task
 public function actionSearch()
 {
     $list = [];
     try {
         Yii::$app->errorHandler->unregister();
         $list = TweetElastic::find()->filter($_POST['filter'])->all();
     } catch (\Exception $e) {
         Yii::$app->errorHandler->exception->type = null;
         Yii::$app->errorHandler->register();
         // var_dump($_POST['filter']['geo_bounding_box']['position']['bottom_right']['lat']);
         $list = Tweet::find()->where('latitude > :latitude', [':latitude' => $_POST['filter']['geo_bounding_box']['position']['bottom_right']['lat']])->andWhere('latitude < :latitude2', [':latitude2' => $_POST['filter']['geo_bounding_box']['position']['top_left']['lat']])->andWhere('longitude < :longitude', [':longitude' => $_POST['filter']['geo_bounding_box']['position']['bottom_right']['lon']])->andWhere('longitude > :longitude2', [':longitude2' => $_POST['filter']['geo_bounding_box']['position']['top_left']['lon']])->all();
     }
     $response = [];
     foreach ($list as $tweet) {
         $response[] = $tweet->getAttributes();
     }
     return json_encode($response);
 }