<?php

namespace app\api\controller\doctor;

use app\common\controller\Apic;
use think\Db;
/**
 * 提建议
 */
class Feedback extends Apic
{
    protected $noNeedLogin = ['typelist'];
    protected $noNeedRight = ['*'];

    public function typelist(){
        $list = Db::name('feedback_type')->select();
        $this->success(1,$list);
    }

    public function addone(){
        $type    = input('type','');
        $info    = input('info','');
        $images  = input('images','');

        if(empty($content)){
            //$this->error('内容不能为空');
        }

        if(!empty($images) && strpos($images,',')){
            if(count(explode(',',$images)) > 8){
                $this->error('一次最多只能上传9张图片');
            }
        }

        $data = [
            'doctor_id' => $this->auth->id,
            'type'      => $type,
            'info'      => $info,
            'images'    => $images,
            'createtime' => time(),
            'updatetime' => time(),
        ];

        $id = Db::name('doctor_feedback')->insertGetId($data);
        $this->success('反馈成功');
    }
/////////////////////////////////////////////////////////////////////
    //我提出的建议
    public function lists(){
        $list = Db::name('doctor_feedback')->where('doctor_id',$this->auth->id)->order('id desc')->autopage()->select();
        $list = list_domain_image($list,['images']);
        $this->success('success',$list);
    }
}
