public function actionShow($u = 1)
 {
     $model = $this->findModel('\\common\\models\\Resource', $u);
     $model->views += 1;
     $model->save();
     //写入观看记录
     if (!Yii::$app->user->isGuest) {
         if (!($uc = \common\models\UserCourse::find()->where(['uid' => Yii::$app->user->id, 'type' => $model->type, 'rid' => $model->id])->one())) {
             $uc = new \common\models\UserCourse();
             $uc->uid = Yii::$app->user->id;
             $uc->type = $model->type;
             $uc->rid = $model->id;
         }
         $uc->save();
     }
     return $this->render('show', ['model' => $model]);
 }
 /**
  * 我的课程
  *
  * @return mixed
  */
 public function actionCourse($type)
 {
     $where[] = 'and';
     $where[] = ['type' => $type];
     $where[] = ['uid' => Yii::$app->user->id];
     $query = \common\models\UserCourse::find()->where($where);
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 8], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     return $this->render('course', ['models' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination, 'type' => $type]);
 }