HospitalModel.php 3.4 KB
<?php
/**
 * Created by PhpStorm.
 * auther: sgj
 * Date: 2018/11/25
 * Time: 17:04
 */

namespace app\admin\model;


use think\Db;
use think\Model;
use traits\model\SoftDelete;

class HospitalModel extends Model
{

    use SoftDelete;
    protected  $deleteTime = 'delete_time';
    protected $insert =['addtime'];

    /**
     * 自动填充数据
     * @return mixed
     */
    protected function setAddtimeAttr()
    {
        return time();
    }
    /**
     * 返回平台信息
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
        public function getPlatment($platment=''){
            if (empty($platment)){
                $map['parent_id']='0';
                $map['delete_time']='0';
                $platment=db('portal_category')->where($map)->select();
            }else{
                $platment=db('portal_category')->where('id',$platment)->select();
            }
            return $platment;
        }

    /**
     * 获取医院
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
        public function getHospital($platform_id=''){
            if ($platform_id!=''){
                $map['platform_id']=$platform_id;
            }else{
                $map='';
            }
            $hospital=$this->where($map)->select();
            return $hospital;
        }

    /**
     * 删除医院
     * @param $hosptial_id
     * @return int
     */
        public function hospitalDel($hosptial_id){
            $result=$this::destroy($hosptial_id);
            return $result;
        }

        public function hospitalAdd($name){
            $this->data([
                'name'  =>  $name,

            ]);
         return    $this->save();
        }

        /**
         * 获取平台内部医院
         * @param $platform 平台id
         * @return mixed
         */
        public function getHospitalByPaltform($platform){
            $map['platform_id']=$platform;
            $info=db('platform_info_view')->field('hospital_name,hospital_id')->where($map)->select();
            return $info;
        }
        /**
         * 通过 平台 医院获取科室
         * @param $platform 平台id
         * @param $hospital 医院id
         * @return mixed
         */
        public function getOfficeByHP($platform,$hospital){
            if (!empty($platform)){
                $map['platform_id']=$platform;
            }
            $map['hospital_id']=$hospital;

            $info=\db('platform_info_view')->field('office_name,office_id')->where($map)->select();
            return $info;
        }

        public function getPaltform($platform=''){
            if (empty($platform)){
                $map['parent_id']='0';
            }else{
                $map['id']=$platform;
            }
            $map['delete_time']='0';
            $info=db('portal_category')->field('name,id')->where($map)->select();
            return $info;
        }

        public function getJob(){

        }

        public function getAllOffice(){
            $office=db('office')->select();
            return $office;
        }




}