public function actionIndex() { $topics = Post::find()->limit(20)->where(['status' => 2])->orderBy(['created_at' => SORT_DESC])->all(); $users = UserService::findActiveUser(12); $statistics = array(); $statistics['post_count'] = Post::find()->count(); $statistics['comment_count'] = PostComment::find()->count(); $statistics['online_count'] = Session::find()->where(['>', 'expire', time()])->count(); return $this->render('index', ['topics' => $topics, 'users' => $users, 'statistics' => $statistics]); }
public function actionIndex() { $topics = Post::find()->limit(20)->where(['status' => 2])->orderBy(['created_at' => SORT_DESC])->all(); $users = UserService::findActiveUser(12); $headline = Arr::getColumn(RightLink::find()->where(['type' => RightLink::RIGHT_LINK_TYPE_HEADLINE])->all(), 'content'); $statistics = []; $statistics['post_count'] = Post::find()->count(); $statistics['comment_count'] = PostComment::find()->count(); $statistics['online_count'] = Session::find()->where(['>', 'expire', time()])->count(); return $this->render('index', ['topics' => $topics, 'users' => $users, 'statistics' => $statistics, 'headline' => Arr::arrayRandomAssoc($headline)]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Session::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'start_time' => $this->start_time, 'hall_id' => $this->hall_id, 'movie_id' => $this->movie_id]); return $dataProvider; }