Collection::append() 判断数据是否存在(null)

调用collection()->append(['关联'=>['属性']]),如果遇到某个模型对象的关联查询到null,则append会导致null object错误
This commit is contained in:
Hanqing Sun
2017-07-29 20:41:13 +08:00
committed by ThinkPHP
parent d1c2044745
commit 80ea6df367

View File

@@ -85,7 +85,7 @@ class Collection extends BaseCollection
{
$this->each(function ($model) use ($append, $override) {
/** @var Model $model */
$model->append($append, $override);
$model && $model->append($append, $override);
});
return $this;
}