ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[danger] hidden() 隐藏关联属性 + 预载入默认显示关联数据的所有字段 ~~~ $data = self::with('comments')->select(); dump($data->toArray()); ~~~ ![](https://img.kancloud.cn/6c/d6/6cd665c3034b712e4385fbb4da2c7c2c_534x540.png) + 隐藏后的效果 ~~~ $data = self::with('comments') ->hidden(['comments.id']) ->select(); dump($data->toArray()); ~~~ ![](https://img.kancloud.cn/27/e8/27e82de802a49d763a5ade8e66fe42c3_363x488.png) + 隐藏多个关联数据的属性 ~~~ $data = self::with('comments') // 隐藏多个关联数据的属性 ->hidden(['comments' => ['id', 'aid']]) ->select(); dump($data->toArray()); ~~~ ![](https://img.kancloud.cn/60/e7/60e715fb08e11cea5776875c8176157f_378x406.png)