protected function generatePivotTablename($class1, $class2, $inverse, $morph=null)
    {
        // datamapper namespace tables
        if ($this->namespaceTablenames) {
            $base = ($inverse)
                ? $this->generateTableName($class1, true)
                : $this->generateTableName($class2, true);

            $related = (! empty($morph))
                ? $morph
                : (! empty($inverse)
                    ? snake_case(class_basename($class2))
                    : snake_case(class_basename($class1)));

            return $base . '_' . $related . '_pivot';
        }

        // eloquent default
        $base = snake_case(class_basename($class1));

        $related = snake_case(class_basename($class2));

        $models = array($related, $base);

        sort($models);

        return strtolower(implode('_', $models));
    }