Skip to content

Commit 1bd41e5

Browse files
committed
feat(core): 模型类型标记类增加静态重载功能
1 parent 6fb5d2f commit 1bd41e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

app/Types/Models.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Models
3434
*/
3535
public const KEY_BY_CLASS_ALIAS = 'class alias';
3636

37+
protected static $instance;
38+
3739
/**
3840
* Types.
3941
* @var array
@@ -42,6 +44,7 @@ class Models
4244
\Zhiyi\Plus\Models\FeedTopic::class => 'types/models/feed-topics',
4345
\Zhiyi\Plus\Models\User::class => 'users', /* 旧关系别名,保持不变 */
4446
\Zhiyi\Plus\Models\Comment::class => 'comments', /* 旧关系别名,保持不变 */
47+
\Zhiyi\Component\ZhiyiPlus\PlusComponentFeed\Models\Feed::class => 'feeds', /* 旧关系别名,保持不变 */
4548
];
4649

4750
/**
@@ -72,4 +75,13 @@ public function all(?string $keyBy = self::KEY_BY_CLASSNAME): array
7275

7376
return static::$types;
7477
}
78+
79+
public static function __callStatic($method, $params)
80+
{
81+
if (!static::$instance instanceof static) {
82+
static::$instance = new static;
83+
}
84+
85+
return static::$instance->$method(...$params);
86+
}
7587
}

0 commit comments

Comments
 (0)