douhuang1973 2016-03-23 11:11
浏览 26
已采纳

Jenssegers MongoDB可填充点符号

I'm trying to get the dot notation working in Jenssegers MongoDB package for Laravel. According this issue it's already been implemented:

link

But it doesn't seem to work in the latest version.

protected $fillable = ['title', 'some.data'];

Doesn't work. But if I open it all up it works fine.

protected $guarded = [];

So that works, not sure if this feature is still there or I need to pre filter my fields manually for now?

  • 写回答

1条回答 默认 最新

  • drzrdc1766788 2016-07-13 19:29
    关注

    Nested fields are not currently supported in $fillable.

    Unfortunately this means you have to do it manually. There are two ways to go: If you have an embedded Some model, you can set $fillable on that, create/fill it with new data, then attach it to the parent model.

    If you don't have/want a whole separate model for your subdocument, you would have to define e.g. $someFillable = ['data']; and use that to filter your new $some data prior to manually setting it on the model. You can basically just copy how Eloquent does it in its fill method.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了