Yes, it is possible to set the parent_id when using the upsert method. You can use the updateOrCreate method to achieve this. The updateOrCreate method will first attempt to locate a database record using the given column values. If the model can not be found, a new record will be inserted with the given attributes.