I am retrieving data from an API response and then save it to the database. There are some fields from the API response that I'd like to ignore when inserting to the database, because those fields do not exist in the table. I learned that it works by assigning the necessary fields to $fillable on the model, and this automatically ignores the fields, however it only works for Model::create($singleRowWithAttributesNotInTable)
which only inserts a single row, but I'd like to perform a bulk insert with multiple rows. Model::insert($multipleRowsWithAttributesNotInTable)
does the bulk insert however it ignores the $fillable variable and returns a Column not found
error.
Is there any way to do this, or do I have to loop through the API data and add Model::create()
inside the loop? Thank you!