Beispiel #1
0
 public function actionDetail($id)
 {
     if (!empty($id)) {
         $new = News::findOne($id);
         $user_exp = TUser::find()->select('name,level')->orderBy('totalexp DESC')->limit(9)->all();
         return $this->render('detail', ['new' => $new, 'users' => $user_exp]);
     }
 }
Beispiel #2
0
 public function actionIndex()
 {
     $news = News::find()->andWhere(['status' => 1]);
     $pages = new Pagination(['totalCount' => $news->count(), 'defaultPageSize' => 5]);
     $models = $news->offset($pages->offset)->limit($pages->limit)->all();
     $user_exp = TUser::find()->select('name,level')->orderBy('totalexp DESC')->limit(9)->all();
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'users' => $user_exp]);
 }
Beispiel #3
0
 public function actionRemove($id)
 {
     if (!empty($id)) {
         $news = News::findOne($id);
         if (!empty($news)) {
             $result = $news->delete();
             if ($result) {
                 return $this->redirect('index');
             } else {
                 \Yii::$app->session->setFlash('error', "Xóa không thành công");
             }
         }
     }
 }
 public function actionRemove($id)
 {
     if (!empty($id)) {
         $cate = NewsCategories::findOne($id);
         $news = News::findAll(['category_id' => $cate->id]);
         if (!empty($news)) {
             \Yii::$app->session->setFlash('error', "Vui lòng xóa tin tức trước khi xóa nhóm.");
         } else {
             if (!empty($cate)) {
                 $result = $cate->delete();
                 if ($result) {
                     return $this->redirect('index');
                 } else {
                     \Yii::$app->session->setFlash('error', "Xóa không thành công");
                 }
             }
         }
     }
 }