I'm trying to get the dot notation working in Jenssegers MongoDB package for Laravel. According this issue it's already been implemented:
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?
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.