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

namespace app\admin\model;


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

class OfficeModel 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 getHospital($platment=''){
            if (empty($platment)){
                $map['parent_id']='0';
                $map['delete_time']='0';
                $platment=db('hospital')->where($map)->select();
            }else{
                $platment=db('hospital')->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 getOffice($hospital_id){
            $map['hospital_id']=$hospital_id;
            $office=$this->where($map)->select();
            return $office;
        }

    /**
     * 删除科室
     * @param $office_id 科室id
     * @return int
     */
        public function officeDel($office_id){
            $result=$this::destroy($office_id);
            return $result;
        }

        public function officeAdd($id,$name,$platform){
            $this->data([
                'name'  =>  $name,
                'hospital_id' =>  $id,
                'platform' =>  $platform
            ]);
         return  $this->save();
        }
        
}