PHP - Importing columns from uploaded CSV file to SQL database (Laravel 5.7)
I defined the fields that I wanted to be required first. Then, I defined a One-to-Many relationship between an account table and a contacts table where the contact id is the account's name in the account's table in the SQL database

        $account = new Account();
                $mapping = $request-&gt;$mapping;
                $account-&gt;name = $rowProperties[$mapping['account_name']];

                //One-To-Many Eloquent Relationship that links a table of Account Names in the Account's 
                //table to contact Account_ID's in the Contact tables  
                //$contact-&gt;id = $account-&gt;id;

                $account-&gt;save();

                $contact = new Contact();
                $contact-&gt;id = $account-&gt;id;
                $contact-&gt;contact_id = $rowProperties[$mapping['contact_account_name']];
                $contact-&gt;first_name = $rowProperties[$mapping['contact_first_name']];
                $contact-&gt;last_name = $rowProperties[$mapping['contact_last_name']]; 


    account = new Account();
                $account-&gt;name = $rowProperties[$mapping['account_name']];
                $this-&gt;account-&gt;hasMany('contact_account_names');
                //$accountid-&gt;contact_account_name
                $account-&gt;save();