Closed alariva closed 5 years ago
Hum..
To import attributes, I'm just doing $this->importable->create($attributes)
, so if your created_at
and updated_at
are not in $fillables
it will not work (and . And I do not recommend putting them in it, as I could be complicated for Laravel to handle that.
Maybe we could change create
to forceCreate
? Actually I'm not comfortable with that as it would be a massive breaking change, and it could pretty dangerous...
Putting created and updated on fillable was the source of the problem (I didn't intend that but came along from old code).
So I think if it should not be filled, it's ok. Lets not break anything.
I will see what the options are in order not to loose them (I actually mind about creation more than update).
Ill keep you posted!
Hi @mathieutu , sorry for the radio silence, I've been busy these weeks and I guess you as well. This is what I plan to do: since I need to recover creation date at import time, I'll fork and address this ability the most elegant and less intrusive way possible that I can, in order to allow me get the duty done and you to merge a PR only if you find it useful (at your discretion). Also keep this issue open or closed at your discretion. I'll keep you posted about news as soon as I can. Thanks a lot!
Hi @mathieutu
After taking some time to dig into this task, finally, I managed to set a non-breaking change that allows me to import timestamps (created_at
and updated_at
) only if they are present on the JSON.
While there still room for improvement, I've done as much as possible to be the least intrussive on the solution, however, it's still kind of a feature that you might prefer to keep off if not needed.
So I'll use the forked version to perform the import that I require as I'll keep both the forked version and a sandbox project with tests as a reference in case anyone ever needs this function.
I'll keep you posted on updates about my migration process! Thanks and regards!
I'm closing that, and let you open a new issue if needed.
Out from solving https://github.com/mathieutu/laravel-json-syncer/issues/2
I have a new and derived problem, that is how do I fill the created and update fields from the imported json data? I would like to keep the same information I exported. Is that possible?