/** * Displays a single Photo model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); $albumModel = Album::findOne($model->album_id); $photoCount = Photo::find()->andWhere(['album_id' => $model->album_id])->count('*'); $currentPage = Photo::find()->andWhere(['album_id' => $model->album_id])->andWhere('id >= ' . $id)->count('*'); return $this->render('photoView', ['model' => $model, 'photoCount' => $photoCount, 'currentPage' => $currentPage, 'albumModel' => $albumModel, '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()]); }
/** * 个人歌单 * @param $userId * @return array */ public function personalSongKingdomByUserId($userId) { $query = SongKingdom::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()]; }
/** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if ($this->validate()) { $user = new User(); $user->username = $this->username; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); if ($user->save()) { $userExtend = new UserExtend(); $resultFullPath = $userExtend->defaultUserImage(); if (!empty($resultFullPath)) { $userExtend->user_id = $user->id; $userExtend->avatar = $resultFullPath['avatar']; $userExtend->image = $resultFullPath['image']; $userExtend->save(); } return $user; } } return null; }
* Date: 2015/12/16 * Time: 10:00 */ use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\Menu; use yii\widgets\Breadcrumbs; use frontend\assets\FrontendAsset; yii::beginProfile('mainAsset', 'gx'); FrontendAsset::register($this); yii::endProfile('mainAsset', 'gx'); $this->title = 'admin'; $baseUrl = Yii::getAlias('@web'); $imgDomain = Yii::$app->params['imgDomain']; if (!Yii::$app->getUser()->isGuest) { $userExtendModel = \common\models\user\UserExtend::find()->andWhere(['user_id' => Yii::$app->getUser()->getId()])->one(); $userModel = \common\models\user\User::findOne(Yii::$app->getUser()->getId()); } ?> <?php $this->beginPage(); ?> <!DOCTYPE html> <html lang="<?php echo Yii::$app->language; ?> " xmlns="http://www.w3.org/1999/html"> <head>
/** * Displays a single Diary model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); return $this->render('diaryView', ['model' => $model, '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()]); }
public function getComment($operateId) { $query = (new Query())->select('a.*')->addSelect('b.username as username')->addSelect('c.avatar')->from(PhotoComment::tableName() . ' as a')->leftJoin(['b' => User::tableName()], 'a.user_id = b.id')->leftJoin(['c' => UserExtend::tableName()], 'a.user_id = c.user_id')->where('1=1')->andWhere(['a.photo_id' => $operateId])->orderBy(['a.created_at' => SORT_ASC]); return $query->createCommand()->queryAll(); }
public function getUserResponse($userId) { $Query = (new Query())->select('b.comment_content,b.created_at')->addSelect('c.username')->addSelect('c.realname')->addSelect('d.avatar')->from(Diary::tableName() . ' as a')->leftJoin(['b' => DiaryComment::tableName()], 'b.diary_id = a.id')->leftJoin(['c' => User::tableName()], 'b.user_id = c.id')->leftJoin(['d' => UserExtend::tableName()], 'd.user_id = c.id')->where('1=1')->andFilterWhere(['a.created_by' => $userId])->andFilterWhere(['b.comment_id' => 0])->andFilterWhere(['b.comment_type' => 0])->orderBy(['b.created_at' => SORT_DESC])->limit(10); $result = $Query->createCommand()->queryAll(); return $result; }