append里面的问题!

浏览:1243 发布日期:2018/09/25
5.0.0 - 严重 - 未处理
$order = OrderModel::get(1);
$order->append('user'=>['nickname','email']);
但是如果这个用户被删除(软删除) 获取到的数据是一个 null

就会有一个异常 Call to a member function visible() on null目前自己修改了框架:      // 追加关联对象属性
                    $relation = $this->getRelation($key);
                    if (!$relation) {
                        $relation = $this->getAttr($key);
                        if ($relation !== null){
                            $relation->visible($name);
                        }
                    }

                    if ($relation === null) {
                        $item[$key] = null;
                    }else{
                        $item[$key] = $relation->append($name)->toArray();
                    }
这样就可以运行了
评论(
后面还有条评论,点击查看>>