提交 85255f83 编写于 作者: weixin_47267244's avatar weixin_47267244

新增为一个列表查询指定关联便捷方法

上级 f6e7c6b6
...@@ -244,4 +244,10 @@ $model->queryRelations('属性名1', '属性名2'); ...@@ -244,4 +244,10 @@ $model->queryRelations('属性名1', '属性名2');
// 查询后可以这么获取结果 // 查询后可以这么获取结果
$data = $model->属性名; $data = $model->属性名;
``` ```
\ No newline at end of file
### 为一个列表查询指定关联
```php
\Imi\Model\Model::queryRelationsList($modelList);
```
...@@ -530,6 +530,24 @@ abstract class Model extends BaseModel ...@@ -530,6 +530,24 @@ abstract class Model extends BaseModel
} }
} }
/**
* 为一个列表查询指定关联.
*
* @param array $list
* @param string ...$names
*
* @return array
*/
public static function queryRelationsList(array $list, string ...$names): array
{
foreach ($list as $row)
{
$row->queryRelations(...$names);
}
return $list;
}
/** /**
* 初始化关联属性. * 初始化关联属性.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册