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)); }
/** * 个人相册 * @param $userId * @return array */ public function personalAlbumByUserId($userId) { $query = Album::find()->andWhere(['created_by' => $userId]); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $pages->setPageSize(10); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return ['models' => $models, 'pages' => $pages, 'userCreadedBy' => User::find()->andWhere(['id' => $userId])->asArray()->one(), 'userExtendCreadedBy' => UserExtend::find()->andWhere(['user_id' => $userId])->asArray()->one()]; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search1($params) { fb($params); $query = Album::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, 'recs_count' => $this->recs_count, 'liked_count' => $this->liked_count, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'alt', $this->alt])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'icon', $this->icon])->andFilterWhere(['like', 'cover', $this->cover])->andFilterWhere(['like', 'thumb', $this->thumb])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'privacy', $this->privacy])->andFilterWhere(['like', 'can_reply', $this->can_reply])->andFilterWhere(['like', 'can_watermark', $this->can_watermark])->andFilterWhere(['like', 'desc', $this->desc]); return $dataProvider; }
/** * Lists all Album models. * @return mixed */ public function actionIndex() { $query = Album::find(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $pages->setPageSize(10); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('albumIndex', ['models' => $models, 'pages' => $pages]); // $dataProvider = new ActiveDataProvider([ // 'query' => Album::find(), // ]); // // return $this->render('index', [ // 'dataProvider' => $dataProvider, // ]); }
public function getUserLable($userId) { // TODO: Implement getUserLable() method. return Album::find()->andWhere(['created_by' => $userId])->all(); }