<?php namespace app\model; use support\Model; class MedicalDept extends Model { protected $table = 'medical_dept'; protected $primaryKey = 'dept_id'; protected $dateFormat = 'U'; const CREATED_AT = 'dept_addTime'; const UPDATED_AT = 'dept_updateTime'; public function serializeDate(\DateTimeInterface $date) { return $date->format('Y-m-d H:i:s'); } /** * @Desc 根据主键获取数据 * @Author Gorden * @Date 2024/3/1 15:59 * * @param $id * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null */ public function getByPrimaryKey($id) { return self::where('dept_id', $id)->first(); } /** * 根据path获取指定科室的所有下级 */ public function getAllSubDept($path) { return self::where('dept_path', 'like', $path . '%')->get()->toArray(); } }