NoticeController.php 979 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace frontend\controllers;
  3. use common\models\Information;
  4. use common\models\Notice;
  5. class NoticeController extends BasewechatController
  6. {
  7. //公告列表
  8. public function actionIndex()
  9. {
  10. $datas = Notice::find()->joinWith('information')->where(['bd_notice.status'=>Notice::STATUS_ACTIVE,'bd_information.type'=>Information::INFORMATION ]);
  11. $time = time();
  12. $datas = $datas->andwhere(['<' , 'bd_notice.release_time' , $time]);
  13. $datas = $datas->andwhere(['>' , 'bd_notice.over_time' , $time]);
  14. $datas = $datas->orderBy('bd_notice.updated_at DESC')->all();
  15. return $this->render('index',['datas'=>$datas]);
  16. }
  17. //公告详细
  18. public function actionNotice_detail()
  19. {
  20. $id = \Yii::$app->request->get('id');
  21. $data = Notice::find()->joinWith('information')->where('bd_notice.id = :id',[':id'=>$id])->asArray()->one();
  22. return $this->render('notice_detail',['data'=>$data]);
  23. }
  24. }