/** * 根据user_id查找头像 * @param integer $user_id * @return UserAvatar the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($user_id) { if (($model = UserAvatar::findOne(['user_id' => $user_id])) !== null) { return $model; } else { return null; } }
<aside class="main-sidebar"> <section class="sidebar"> <!-- Sidebar user panel --> <?php $user_avatar = $directoryAsset . '/img/user2-160x160.jpg'; if ($avatar = \common\models\UserAvatar::getAvatar(Yii::$app->user->identity->id)) { $user_avatar = Yii::$app->homeUrl . '/uploads/user/avatar/' . $avatar; } ?> <div class="user-panel"> <div class="pull-left image"> <img src="<?php echo $user_avatar; ?> " class="img-circle" alt="User Image"/> </div> <div class="pull-left info"> <p>超级管理员</p> <a href="#"><i class="fa fa-circle text-success"></i> 在线</a> </div> </div> <!-- search form --> <form action="#" method="get" class="sidebar-form"> <div class="input-group"> <input type="text" name="q" class="form-control" placeholder="搜索..."/> <span class="input-group-btn"> <button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
* (c) Dektrium project <http://github.com/dektrium> * * For the full copyright and license information, please view the LICENSE.md * file that was distributed with this source code. */ use yii\helpers\Html; /* * @var yii\web\View $this * @var yii\widgets\ActiveForm $form * @var dektrium\user\models\Profile $profile */ $this->title = Yii::t('user', 'Profile settings'); $this->params['breadcrumbs'][] = $this->title; $user = Yii::$app->user->identity; $user_avatar = Yii::$app->homeUrl . '/uploads/user/default/user2-160x160.jpg'; if ($avatar = \common\models\UserAvatar::getAvatar($user->id)) { $user_avatar = Yii::$app->homeUrl . '/uploads/user/avatar/' . $avatar; } ?> <div class="box box-primary"> <div class="box-body"> <div class="row"> <div class="col-md-3"> <?php echo $this->render('_menu'); ?> </div> <div class="col-md-9"> <div class="panel panel-info"> <div class="panel-heading"> <?php