Creates the proper underscored model key for associations

If the input contains a dot, assume that the right side is the real table name.

@param string $name Model class name
@return string Singular model key
439947
protected function _modelKey($name)
    {
        list(, $name) = pluginSplit($name);

        return Inflector::underscore(Inflector::singularize($name)) . '_id';
    }
476272
public function getTable($name = '')
    {
        if ($name || empty($this->table)) {
            $name      = $name ?: $this->name;
            $tableName = $this->prefix;
            if ($name) {
                $tableName .= Parse::parseName($name);
            }
        } else {
            $tableName = $this->table;
        }
        return $tableName;
    }
202266
private function _uniqueCorrelation($name)
    {
        if (is_array($name)) {
            $c = end($name);
        } else {
            // Extract just the last name of a qualified table name
            $dot = strrpos($name,'.');
            $c = ($dot === false) ? $name : substr($name, $dot+1);
        }
        for ($i = 2; array_key_exists($c, $this->_parts[self::FROM]); ++$i) {
            $c = $name . '_' . (string) $i;
        }
        return $c;
    }
1229250
public function getRawSQLName($name)
    {
        $names = $this->metadata[Metadata::RAW_NAMES];
        
        if (isset($names[$name]))
            return $names[$name];
        
        throw new NotFoundException('Cannot found real column name for ":name"', ['name' => $name]);
    }
1064487
protected static function _getKeyTag( $name )
    {
        //	If this is an array, apply to all keys
        if ( is_array( $name ) )
        {
            $_items = array();

            foreach ( $name as $_key => $_value )
            {
                $_items[$_key] = $_value;
            }

            return $_items;
        }

        if ( is_string( $name ) )
        {
            $_tag = Inflector::neutralize( $name );

            return $_tag;
        }

        //	Dunno, have it back the same I guess...
        return $name;
    }
801723
protected function underscore($name)
    {
        if (isset(self::$underscoreCache[$name])) {
            return self::$underscoreCache[$name];
        }
        $result                       = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
        self::$underscoreCache[$name] = $result;

        return $result;
    }
230574
protected function parseName($name) {
        $tableName = $name;
        $suffix = NULL;

        $pos = strrpos($name, '_');
        if ($pos !== FALSE) {
            $tableId = substr($name, $pos + 1);
            if (is_numeric($tableId)) {
                $tableName = substr($name, 0, $pos);
                $suffix = intval($tableId);
            }
        }

        return array($tableName, $suffix);
    }
351281
protected function getScaffoldedTemplate($name)
    {
        $model = $this->cache->getModelName();  // post
        $models = Pluralizer::plural($model);   // posts
        $Models = ucwords($models);             // Posts
        $Model = Pluralizer::singular($Models); // Post

        // Create and Edit views require form elements
        if ($name === 'create.blade' or $name === 'edit.blade')
        {
            $formElements = $this->makeFormElements();

            $this->template = str_replace('{{formElements}}', $formElements, $this->template);
        }

        // Replace template vars in view
        foreach(array('model', 'models', 'Models', 'Model') as $var)
        {
            $this->template = str_replace('{{'.$var.'}}', $$var, $this->template);
        }

        // And finally create the table rows
        list($headings, $fields, $editAndDeleteLinks) = $this->makeTableRows($model);
        $this->template = str_replace('{{headings}}', implode(PHP_EOL."\t\t\t\t", $headings), $this->template);
        $this->template = str_replace('{{fields}}', implode(PHP_EOL."\t\t\t\t\t", $fields) . PHP_EOL . $editAndDeleteLinks, $this->template);

        return $this->template;
    }
1131048
protected function _getForeignKey(Table $table, string $modelName) : string
    {
        foreach ($table->associations() as $association) {
            if ($modelName !== $association->className()) {
                continue;
            }

            $primaryKey = $association->getForeignKey();
            if (! is_string($primaryKey)) {
                throw new RuntimeException('Primary key must be a string');
            }

            return $primaryKey;
        }

        return '';
    }
779307
public function getUsStateAbbreviationForName($name)
    {
        if (!in_array($name, self::$usStates)) {
            return null;
        }

        return (string) array_search($name, self::$usStates);
    }
187346
protected function getForeignKeyName(Model $model)
    {
        $table = $model->getTable();

        if (array_key_exists($table, $this->foreignKeyLookup)) {
            return $this->foreignKeyLookup[$table];
        }

        return Str::singular($table).'_id';
    }
297225
private function fullyQualifiedDatabaseName($name)
    {
        $instance = InstanceAdminClient::parseName($this->instance->name())['instance'];

        try {
            return GapicSpannerClient::databaseName(
                $this->projectId,
                $instance,
                $name
            );
        //@codeCoverageIgnoreStart
        } catch (ValidationException $e) {
            return $name;
        }
        //@codeCoverageIgnoreEnd
    }
1273255
protected function resolveKey($name)
    {
        if (false !== $pos = strrpos($name, $this->namespaceCharacter)) {
            $name = substr($name, $pos + 1);
        }

        return $name;
    }
1139390
protected function getModelValueAttribute($name)
    {
        $key = $this->transformKey($name);

        if (method_exists($this->model, 'getFormValue')) {
            return $this->model->getFormValue($key);
        }

        return data_get($this->model, $this->transformKey($name));
    }
371082
public function getMappingName($name)
    {
        return isset($this->mapping[$name]) ? $this->mapping[$name] : $name;
    }
393109
public function quoteIdentifier($name)
    {
        $quote = null;
        switch ($this->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
            case 'pgsql':
            case 'sqlsrv':
            case 'dblib':
            case 'mssql':
            case 'sybase':
                $quote = '"';
                break;
            case 'mysql':
            case 'sqlite':
            case 'sqlite2':
            default:
                $quote = '`';
        }

        $parts = explode('.', $name);
        foreach ($parts as $k => $part) {
            if ($part !== '*') {
                $parts[$k] = $quote . $part . $quote;
            }
        }

        return implode('.', $parts);
    }
339544
protected function getKey($name) {

        if(false === isset($_COOKIE[$name]) || '' === $_COOKIE[$name]) {

            $key 		 = static :: random_bytes(64); //32 for encryption and 32 for authentication
            $cookieParam = session_get_cookie_params();

            setcookie($name, base64_encode($key), ($cookieParam['lifetime'] > 0) ? time() + $cookieParam['lifetime'] : 0, $cookieParam['path'], $cookieParam['domain'], $cookieParam['secure'], $cookieParam['httponly']);
        }
        else {
            $key = base64_decode($_COOKIE[$name]);
        }

        return $key;
    }