SingleController.php 820 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace addons\TinyBlog\frontend\controllers;
  3. use Yii;
  4. use yii\web\UnprocessableEntityHttpException;
  5. use addons\TinyBlog\common\models\Single;
  6. /**
  7. * Class SingleController
  8. * @package addons\TinyBlog\frontend\controllers
  9. * @author jianyan74 <751393839@qq.com>
  10. */
  11. class SingleController extends BaseController
  12. {
  13. /**
  14. * @return string
  15. */
  16. public function actionView()
  17. {
  18. $id = Yii::$app->request->get('single_id');
  19. $model = Yii::$app->tinyBlogService->single->findById($id);
  20. if (empty($model)) {
  21. throw new UnprocessableEntityHttpException('找不到文章内容...');
  22. }
  23. Single::updateAllCounters(['view' => 1], ['id' => $model['id']]);
  24. return $this->render($this->action->id,[
  25. 'model' => $model
  26. ]);
  27. }
  28. }
粤ICP备19079148号