Replies: 2 comments 1 reply
-
Hi @dgillier, Did you find a solution for this? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Seems I found a solution in the docs https://docs.laravel-excel.com/3.1/imports/model.html#handling-persistence-on-your-own. Here is an example based on your question. I leave it here, maybe it will help others in future. `public function onRow(\Maatwebsite\Excel\Row $row)
}` |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to import some data and I have belongsToMany relationships in my Model.
I've got this in my User model :
public function leadershipStatus() { return $this->belongsToMany(LeaderStatus::class); }
I tried this ImportClass model function with ToModel:
($this->leaderships is loaded in a construct function)
I've got this error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null
It's failing because at this stage there is no id assigned to the record...
(I 'm also using 'WithUpserts')
Any suggestion on how to do that ?
Thanks, Denis
Beta Was this translation helpful? Give feedback.
All reactions