Import Action: Create or update on other table

Hello, I was trying to import the Students CSV file and it's working fine and it has a relationship to Sections model. How can I import the $data['section'] column to my Sections model from resolveRecord() or is there a right way to do that, TIA ❤️
No description
No description
6 Replies
IamJohnDev
IamJohnDevOP12mo ago
Up
Hussain4real
Hussain4real12mo ago
Is there a 'section_id' column on your students table?
IamJohnDev
IamJohnDevOP12mo ago
im using the section_id as section_name here's the table
No description
No description
Hussain4real
Hussain4real12mo ago
you need an importer column like this '''ImportColumn::make('section') ->requiredMapping() ->relationship(resolveUsing: ['name']) ''' then in your csv file specify the name of the section in the relationship name column
IamJohnDev
IamJohnDevOP12mo ago
will this create a record if the section is not existing on the table? I will try it later, Thank you ❤️
Hussain4real
Hussain4real12mo ago
No, it throw an error if it doesn't exist
Want results from more Discord servers?
Add your server