Skip to content

Commit b0904aa

Browse files
committed
配置参数统一使用驼峰命名
1 parent 778a8da commit b0904aa

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

src/Model.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ public function __construct(array | object $data = [])
115115
'relation' => [],
116116
'together' => [],
117117
'allow' => [],
118-
'with_attr' => [],
118+
'withAttr' => [],
119119
'schema' => $options['schema'] ?? [],
120-
'update_time' => $options['update_time'] ?? 'update_time',
121-
'create_time' => $options['create_time'] ?? 'create_time',
120+
'updateTime' => $options['updateTtime'] ?? 'update_time',
121+
'createTime' => $options['createTime'] ?? 'create_time',
122122
'suffix' => $options['suffix'] ?? '',
123123
'pk' => $options['pk'] ?? 'id',
124124
'validate' => $options['validate'] ?? $this->parseValidate(),
@@ -130,9 +130,8 @@ public function __construct(array | object $data = [])
130130
'append' => $options['append'] ?? [],
131131
'mapping' => $options['mapping'] ?? [],
132132
'strict' => $options['strict'] ?? true,
133-
'bind_attr' => $options['bind_attr'] ?? [],
134-
'auto_relation' => $options['auto_relation'] ?? [],
135-
'relation_keys' => $options['relation_keys'] ?? [],
133+
'bindAttr' => $options['bindAttr'] ?? [],
134+
'autoRelation' => $options['autoRelation'] ?? [],
136135
];
137136

138137
// 设置额外参数
@@ -594,7 +593,7 @@ public function __get(string $name)
594593
*/
595594
public function __set(string $name, $value): void
596595
{
597-
if ($value instanceof Modelable && $bind = $this->getBindAttr($this->getOption('bind_attr'), $name)) {
596+
if ($value instanceof Modelable && $bind = $this->getBindAttr($this->getOption('bindAttr'), $name)) {
598597
// 关联属性绑定
599598
$this->bindRelationAttr($value, $bind);
600599
} else {

src/model/concern/Attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function withAttr(string $name, callable $callback)
157157
{
158158
$name = $this->getRealFieldName($name);
159159

160-
$this->setWeakData('with_attr', $name, $callback);
160+
$this->setWeakData('withAttr', $name, $callback);
161161
// 自动追加输出
162162
self::$weakMap[$this]['append'][] = $name;
163163
return $this;
@@ -565,7 +565,7 @@ private function getWithAttr(string $name, $value, array $data = [])
565565
{
566566
$attr = Str::studly($name);
567567
$method = 'get' . $attr . 'Attr';
568-
$withAttr = $this->getWeakData('with_attr', $name);
568+
$withAttr = $this->getWeakData('withAttr', $name);
569569
if ($withAttr) {
570570
// 动态获取器
571571
$value = $withAttr($value, $data, $this);

src/model/concern/DbConnect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ public static function __callStatic($method, $args)
202202

203203
$db = $model->getQuery();
204204

205-
if (!empty(self::$weakMap[$model]['auto_relation'])) {
205+
if (!empty(self::$weakMap[$model]['autoRelation'])) {
206206
// 自动获取关联数据
207-
$db->with(self::$weakMap[$model]['auto_relation']);
207+
$db->with(self::$weakMap[$model]['autoRelation']);
208208
}
209209

210210
return call_user_func_array([$db, $method], $args);

src/model/concern/RelationShip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private function parseRelationData(array $relations)
6464
foreach ($relations as $relation => $val) {
6565
$relation = $this->getRealFieldName($relation);
6666
$type = $this->getFields($relation);
67-
$bind = $this->getBindAttr($this->getOption('bind_attr'), $relation);
67+
$bind = $this->getBindAttr($this->getOption('bindAttr'), $relation);
6868
if (!empty($bind)) {
6969
// 绑定关联属性
7070
$this->bindRelationAttr($val, $bind);

0 commit comments

Comments
 (0)