<?php

namespace app\admin\controller;

use app\admin\BaseController;
use app\common\model\Feedback as FeedbackModel;

class Feedback extends BaseController
{

    // 列表
    public function feedbacklist()
    {
        return view('feedback/feedbacklist');
    }

    public function listfeedback()
    {
        $limit = input('limit');
        $page = input('page');
        $map         = [];
        $status = input('status/d');
        if (!empty($status)) {
            $map[] = ['status', '=', $status];
        }
        $list = FeedbackModel::with('user')->where($map)->order(['createtime'=>'desc'])->limit($limit)->page($page)->append(['status_text'])->select();
        $count = FeedbackModel::where($map)->count();
        if ($count==0){
            exit(json_encode(array(
                'code' 	=> 1,
                'msg'	=> "未查询到数据"
            )));
        }
        exit(json_encode(array(
            'code' 	=> 0,
            'msg'	=> "",
            'count' => $count,
            'data'  => $list
        )));
    }

    public function dealfeedback()
    {
        $idarr = input('idarr/a');
        FeedbackModel::whereIn('id', $idarr)->update(['status' => 1]);
        exit(json_encode([
            'code' => 0,
            'msg'  => "",
        ]));
    }
}