| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?phpnamespace app\model;use DateTimeInterface;use support\Model;class SysDept extends Model{    // 关联表    protected $table = 'sys_dept';    protected $primaryKey = 'dept_id';    protected $dateFormat = 'U';    const CREATED_AT = 'dept_addtimes';    const UPDATED_AT = null;    public function serializeDate(DateTimeInterface $date)    {        return $date->format('Y-m-d H:i:s');    }    public function getByPrimaryKey($id)    {        return self::where('dept_id', $id)->first();    }        /**     * @Desc 获取子部门     * @Author Gorden     * @Date 2024/3/7 14:03     *     * @param $path     * @return array     */    public static function getAllSubDept($path)    {        return self::where('dept_super_path', 'like', $path . '%')->get()->toArray();    }    /**     * @Desc 验证指定字段指定值是否存在     * @Author Gorden     * @Date 2024/3/22 14:52     *     * @param $category     * @param $field     * @param $value     * @return bool     */    public static function checkExist($category, $field, $value)    {        return self::where('dept_category', $category)            ->where($field, $value)            ->exists();    }    public function premises(){        return $this->hasOne(self::class,'dept_id','dept_super_id');    }}
 |