InquiryModel.php 1.9 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\model;

use app\portal\model\PortalPostModel;
use think\Db;
use think\Model;

class InquiryModel extends Model
{
    protected $type = [
        'patient' => 'array',
        'problem' => 'array',
        'diagnose' => 'array',
        'reply' => 'array',
        'problem_again' => 'array',
        'reply_again' => 'array',
    ];

    /**
     * 后台管理添加
     * @param array $data 数据
     * @return $this
     */
    public function adminAdd($data){
        $this->allowField(true)->data($data, true)->isUpdate(false)->save();
        return $this;
    }


    /**
     * 后台管理编辑
     * @param array $data 数据
     * @return $this
     */
    public function adminEdit($data){
        $this->allowField(true)->isUpdate(true)->data($data, true)->save();
        return $this;

    }

    public function getInfo($id){
        $info=$this->alias('a')
            ->join('__USER__ b','a.user_id=b.id','LEFT')
            ->join('__HOSPITAL__ h','h.id=b.hospital',"LEFT")
            ->join('__OFFICE__ o','b.office=o.id',"LEFT")
            ->join('__JOB__ j','b.job=j.id',"LEFT")
            ->field('a.*,b.user_nickname,b.avatar,b.mobile,h.name as hospital,o.name as office,j.name as job')
            ->where(['a.id'=>$id])->find();
        return $info;
    }

}