<?php
/**
 * @copyright   Copyright (c) 2017 https://www.sapixx.com All rights reserved.
 * @license     Licensed (http://www.apache.org/licenses/LICENSE-2.0).
 * @author      pillar<ltmn@qq.com>
 * 新闻首页
 */
namespace app\allwin\controller\home;
use app\common\controller\Api;

class News extends Api{

    /**
     * 新闻阅读
     * @return void
     */
    public function review(int $app,int $id){
        $info = model('News')->where(['member_miniapp_id' => $app,'id' => $id])->find();
        if(empty($info)){
            $this->error('资源不存在');
        }
        $info->views = $info->views+rand(1,5);
        $info->save();
        $info['update_time'] = date('Y-m-d H: i',$info['update_time']);   
        $view['info']        = $info;
        $view['title']       = '同城头条';
        $this->view->engine->layout(false);
        return view()->assign($view);
    }
}