csv import creating data in multiple models
Hello, let's say I have a user and a course. a user can have many courses
and I have a csv with the following data.
userId
, userName
, courseName
, CourseDescription
.
in my database the relation between the courses and the user is made through the userId
, it's a one-to-many relationship
I am in the courses view in filament which has a csv import button,
if I import this csv I am assuming it will be able to fill in the userId
, courseName
and courseDescription
. but my question is: if the userId
doesn't exist in the users table, can filament also create this new user?1 Reply
you could do a firstOrCreate() in the resolveUsing() https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import#customizing-the-relationship-import-resolution