News.php 902 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 新闻首页
  7. */
  8. namespace app\allwin\controller\home;
  9. use app\common\controller\Api;
  10. class News extends Api{
  11. /**
  12. * 新闻阅读
  13. * @return void
  14. */
  15. public function review(int $app,int $id){
  16. $info = model('News')->where(['member_miniapp_id' => $app,'id' => $id])->find();
  17. if(empty($info)){
  18. $this->error('资源不存在');
  19. }
  20. $info->views = $info->views+rand(1,5);
  21. $info->save();
  22. $info['update_time'] = date('Y-m-d H: i',$info['update_time']);
  23. $view['info'] = $info;
  24. $view['title'] = '同城头条';
  25. $this->view->engine->layout(false);
  26. return view()->assign($view);
  27. }
  28. }