public function run()
 {
     $this->hotAlbum = Album::find()->limit(4)->all();
     $this->hotDiary = Diary::find()->limit(10)->all();
     $this->hotSong = Song::find()->limit(5)->orderBy(['created_at' => SORT_DESC])->all();
     return $this->render('home-hot-content', array('hotAlbum' => $this->hotAlbum, 'hotDiary' => $this->hotDiary, 'hotSong' => $this->hotSong));
 }
Exemple #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search1($params)
 {
     $query = Song::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, 'song_time' => $this->song_time, 'liked_count' => $this->liked_count, 'fav_count' => $this->fav_count, 'share_count' => $this->share_count, 'download_count' => $this->download_count, 'comment_count' => $this->comment_count, 'play_count' => $this->play_count, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'singer', $this->singer])->andFilterWhere(['like', 'album', $this->album])->andFilterWhere(['like', 'privacy', $this->privacy])->andFilterWhere(['like', 'can_reply', $this->can_reply])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'cover', $this->cover]);
     return $dataProvider;
 }
Exemple #3
0
 /**
  * Lists all Song models.
  * @param $song_kingdom_id
  * @return mixed
  */
 public function actionIndex($song_kingdom_id)
 {
     $query = Song::find()->andWhere(['created_by' => Yii::$app->getUser()->getId(), 'song_kingdom_id' => $song_kingdom_id]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $pages->setPageSize(10);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('songIndex', ['models' => $models, 'pages' => $pages]);
     //        $dataProvider = new ActiveDataProvider([
     //            'query' => Song::find(),
     //        ]);
     //
     //        return $this->render('index', [
     //            'dataProvider' => $dataProvider,
     //        ]);
 }
 /**
  * Displays a single SongKingdom model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     return $this->render('songKingdomView', ['model' => $model, 'songModels' => Song::find()->andWhere(['song_kingdom_id' => $id])->all(), 'userCreadedBy' => User::find()->andWhere(['id' => $model->created_by])->asArray()->one(), 'userExtendCreadedBy' => UserExtend::find()->andWhere(['user_id' => $model->created_by])->asArray()->one(), 'user' => User::find()->andWhere(['id' => Yii::$app->getUser()->getId()])->asArray()->one(), 'userExtend' => UserExtend::find()->andWhere(['user_id' => Yii::$app->getUser()->getId()])->asArray()->one()]);
 }