\App\ModelsSysRegion

行政地区(省/市/区/街道/村 五级树)

职责:地区档案——公司/部门表单的 region_id 档案字段引用;不参与数据权限推导。 借 SubtreeIds Trait 提供前缀区间子树查询。

Summary

Methods
Properties
Constants
parent()
children()
subtreeIds()
timestampCasts()
companies()
depts()
$timestamps
$incrementing
$id
$parent_id
$ancestors
$name
$level
$sort
$status
$create_time
$update_time
$code
$pinyin
$pinyin_prefix
$longitude
$latitude
$postal_code
$area_code
LEVEL_PROVINCE
LEVEL_CITY
LEVEL_DISTRICT
LEVEL_STREET
LEVEL_VILLAGE
serializeDate()
casts()
$table
$fillable
N/A
No private methods found
No private properties found
N/A

Constants

LEVEL_PROVINCE

LEVEL_PROVINCE = 1

层级:省

LEVEL_CITY

LEVEL_CITY = 2

层级:市

LEVEL_DISTRICT

LEVEL_DISTRICT = 3

层级:区

LEVEL_STREET

LEVEL_STREET = 4

层级:街道

LEVEL_VILLAGE

LEVEL_VILLAGE = 5

层级:村

Properties

$timestamps

$timestamps

$incrementing

$incrementing

id 语义 = 12 位行政区划 code(外部给定):显式 id 一律保留,缺省回落序列默认值

$id

$id : int

主键ID

Type

int

$parent_id

$parent_id : int

父级ID,0=顶级

Type

int

$ancestors

$ancestors : string

祖级路径

Type

string

$name

$name : string

地区名称

Type

string

$level

$level : int

层级:1 省、2 市、3 区、4 街道、5 村(五级)

Type

int

$sort

$sort : int

排序号

Type

int

$status

$status : int

状态:1 启用,0 停用

Type

int

$create_time

$create_time : string

创建时间

Type

string

$update_time

$update_time : string|null

更新时间

Type

string|null

$code

$code : string

行政区划代码,12 位

Type

string

$pinyin

$pinyin : string

拼音

Type

string

$pinyin_prefix

$pinyin_prefix : string

拼音首字母

Type

string

$longitude

$longitude : float|null

经度

Type

float|null

$latitude

$latitude : float|null

纬度

Type

float|null

$postal_code

$postal_code : string

邮编

Type

string

$area_code

$area_code : string

电话区号,如 010/020

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 常量 本地枚举(启停状态 STATUS_* 已单源 HasStatusConstants) 分区 2 · 表名与属性 $table / $fillable / casts 分区 3 · 关联关系 parent / children / companies / depts └────────────────────────────────────────────────────────────┘

Type

string

$table

$table

$fillable

$fillable

Methods

parent()

parent() : \Illuminate\Database\Eloquent\Relations\BelongsTo

上级地区(parent_id=0 顶级时无记录,自然返回 null)

Returns

\Illuminate\Database\Eloquent\Relations\BelongsTo —

children()

children() : \Illuminate\Database\Eloquent\Relations\HasMany

下级地区

Returns

\Illuminate\Database\Eloquent\Relations\HasMany —

subtreeIds()

subtreeIds(int  $id) : int[]

子树(含自身)节点 id 集。

流程:① 查自身 ancestors ② 计算前缀区间 ③ 区间扫描取全部后代 id ④ 补入自身 id 后返回。

Parameters

int $id

Returns

int[] —

timestampCasts()

timestampCasts() : array<string,string>

全库统一的时间列 cast 段(单源:约 22 个模型 casts() 内重复的两行)。 使用方模型 casts() 内 `return array_merge(self::timestampCasts(), [...])`。

Returns

array

companies()

companies() : \Illuminate\Database\Eloquent\Relations\HasMany

位于该地区的组织(档案引用)

Returns

\Illuminate\Database\Eloquent\Relations\HasMany —

depts()

depts() : \Illuminate\Database\Eloquent\Relations\HasMany

位于该地区的部门(档案引用)

Returns

\Illuminate\Database\Eloquent\Relations\HasMany —

serializeDate()

serializeDate(\DateTimeInterface  $date) : string

所有日期属性统一按 "年-月-日 时:分:秒" 序列化。

Parameters

\DateTimeInterface $date

Returns

string —

casts()

casts() : array

Returns

array —