public function actionGetMarketInfo() { $market_id = Yii::$app->request->post('market_id'); if (Yii::$app->getRequest()->isAjax && $market_id) { $market = Markets::findOne($market_id)->toArray(); $markets_images = MarketsImages::find()->where(['markets_id' => $market_id])->asArray()->all(); return $this->renderAjax('markets_popup_content', ['market' => $market, 'markets_images' => $markets_images]); } }
/** * Get markets without filters * @param type $limit * @return type */ public static function getAll($limit = 25) { $sql = "SELECT m.id, m.title, m.xrl_price, m.current_date, mi.thumb_src," . " COUNT(mp.id) AS proposes_count " . " FROM " . self::tableName() . " m " . " JOIN " . MarketsImages::tableName() . " mi " . " ON m.id = mi.markets_id " . " LEFT JOIN " . MarketsProposes::tableName() . " mp " . " ON m.id = mp.markets_id " . " GROUP BY m.id " . " ORDER BY m.id DESC " . " LIMIT :limit "; return static::findBySql($sql, [':limit' => $limit])->asArray()->all(); }