public function associateRelatedRecordsToUpdatedRecord($modelInstance, $associatedRecords, $relatedModelClass)
    {
        // Check if there are any records to sync with the pivot table
        if (count($associatedRecords) > 0)
        {
            // There's probably a function for this, but for now:
            //  (i)  create an array of the related IDs
            //  (ii) detach the existing tag IDs and attach the new tag IDs, by using SYNC

            //  (i)  create an array of the related IDs
            $newIds = array();
            foreach ($associatedRecords as $associatedId)
            {
                $newIds[] = $associatedId;
            }

            // For the purpose of saving to the pivot table, we need the method name of the related model as
            // it is in the model. As the method would be capitalized, let's un-capitalize it
            $relatedMethod = strtolower($relatedModelClass);

            // (ii) detach the existing tag IDs and attach the new tag IDs, by using SYNC
            $modelInstance->$relatedMethod()->sync($newIds);
        }
    }