Get the raw Cypher statements for the blueprint.

@param  \Illuminate\Database\ConnectionInterface  $connection
@param  \Illuminate\Database\Schema\Grammars\Grammar  $grammar
@return array
196311
public function toCypher(ConnectionInterface $connection, IlluminateSchemaGrammar $grammar)
    {
        $statements = [];

        // Each type of command has a corresponding compiler function on the schema
        // grammar which is used to build the necessary SQL statements to build
        // the blueprint element, so we'll just call that compilers function.
        foreach ($this->commands as $command)
        {
            $method = 'compile'.ucfirst($command->name);

            if (method_exists($grammar, $method))
            {
                if ( ! is_null($cypher = $grammar->$method($this, $command, $connection)))
                {
                    $statements = array_merge($statements, (array) $cypher);
                }
            }
        }

        return $statements;
    }
697203
public static function tablesExist(Connection $connection, $tables)
    {
        $result = false;
        if (!empty($tables)) {
            try {
                $connection->connect();
                $result = $connection->getSchemaManager()->tablesExist($tables);
            } catch (\PDOException $e) {
            } catch (DBALException $e) {
            }
        }

        return $result;
    }
764430
public function connection(ConnectionInterface $connection = null)
    {
        deprecationWarning(
            get_called_class() . '::connection() is deprecated. ' .
            'Use setConnection()/getConnection() instead.'
        );
        if ($connection !== null) {
            $this->setConnection($connection);
        }

        return $this->getConnection();
    }
1009301
public function searchDatabase(
        Connection $connection,
        string $databaseName,
        string $searchTerm
    ): \Generator {
        $databaseMetadata = (new MetadataFactory())->getDatabaseMetadata($connection, $databaseName);

        foreach ($databaseMetadata->getAllTableMetadata() as $tableMetadata) {
            $resultList = $this->searchTable(
                $connection,
                $tableMetadata->getDatabaseName(),
                $tableMetadata->getTableName(),
                $searchTerm
            );

            foreach ($resultList as $result) {
                yield $result;
            }
        }
    }
822936
private function createBuilderFromConnection(Connection $connection, string $modelClass): ModelQueryBuilder
    {
        return $this->getFactory()->createModelQueryBuilder($connection, $modelClass, $this->getModelSchemas());
    }
1202098
public function getCount(ConnectionInterface $connection)
    {
        $obj = $this->deepClone();
        $obj->addAnnotation(['annotation' => count_('*'), 'alias' => '_count', 'isSummary' => true]);
        $alias = '_count';
        $result = $obj->getAggregation($connection, [$alias]);

        return ArrayHelper::getValue($result, $alias, 0);
    }
1166634
public function getLanguagesForNode(NodeInterface $node)
    {
        $languages = [];
        foreach ($node->getProperties() as $property) {
            /* @var PropertyInterface $property */
            preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches);

            if ($matches) {
                $languages[$matches[1]] = $matches[1];
            }
        }

        return array_values($languages);
    }
639742
protected function isConnectionActive(ConnectionInterface $connection)
    {
        $connectionKey = $connection->getConnectionKey();
        $defaults = $this->getDefaultConnectionsHandles();

        return
            in_array($connectionKey->toHandle(), $defaults, true) ||
            in_array($connectionKey->name, $defaults, true) ||
            $connection->isActive();
    }
828950
public function getColumns($table, $connection = null)
    {
        $this->updateConnection($connection)->setUpDoctrineSchema();

        $schema  = $this->getSchemaBuilder();
        $columns = $schema->getColumnListing($table);

        $columnData = [];

        foreach ($columns as $name) {

            $column = $schema->getConnection()->getDoctrineColumn($table, $name);

            $columnData[] = [
                'name'     => $column->getName(),
                'type'     => $column->getType()->getName(),
                'length'   => $column->getLength(),
                'values'   => false,
                'unsigned' => $column->getUnsigned(),
                'nullable' => ! $column->getNotnull(),
            ];
        }

        return $columnData;
    }
78691
protected function getSchemaGrammar($connection)
    {
        if (is_null($grammar = $connection->getSchemaGrammar())) {
            $connection->useDefaultSchemaGrammar();

            $grammar = $connection->getSchemaGrammar();
        }

        return $grammar;
    }
967868
protected function getUser(Connection $connection)
    {
        $recaller = $connection->WebSocket->request->getCookie(Auth::getRecallerName());
        
        if (! $recaller) {
            return false;
        }
        
        try {
            $recaller = $this->Encrypter->decrypt(urldecode($recaller));
        } catch (Exception $e) {
            $recaller = $this->Encrypter->decrypt($recaller);
        }
        
        $id = explode('|', $recaller, 2)[0];
        $model = $this->getUserModel();
        
        return $model::find($id) !== null ? $id : false;
    }
1072711
public static function getConnections($connection, $table)
    {
        $connections = DB::connection($connection)->table($table)->get();

        if(!empty($connections)) {
            /**
             * Create an empty array which will get populated with the data from
             * $connections in the correct format within the foreach statement
             * below file generation.
             */
            $config = array();
            /**
             * Generate a random string for the filename as it is temporary
             * and more secure.
             */
            $random_string = ConnectionLoader::random_string(35);
            /**
             * Append the .php extension to the file name and store here
             * storage_path/app/$tempFile with some starting content.
             */
            $tempFileName = $random_string . '.php';
            $tempFile = Storage::disk('local')->put($tempFileName, '<?php return ');

            if ($tempFile === true) {
                /**
                 * Loops through the connections checking the driver and pushes
                 * correctly formatted array into the $config array.
                 */
                foreach ($connections as $connection) {
                    $name = $connection->name;
                    $driver = $connection->driver;

                    if ($driver == 'sqlite') {

                        $connection_config = array(
                            'driver' => $driver,
                            'database' => database_path($connection->database),
                            'prefix' => $connection->prefix,
                        );

                        $config[$name] = $connection_config;

                    } elseif ($driver == 'mysql') {

                        $strict = $connection->strict;
                        if ($strict == 1) {
                            $strict = true;
                        } else {
                            $strict = false;
                        }
                        $password = $connection->password;

                        if(empty($password)) {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => $password,
                                'charset' => $connection->charset,
                                'collation' => $connection->collation,
                                'prefix' => $connection->prefix,
                                'strict' => $strict,
                            );
                        }
                        else {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => Crypt::decrypt($password),
                                'charset' => $connection->charset,
                                'collation' => $connection->collation,
                                'prefix' => $connection->prefix,
                                'strict' => $strict,
                            );
                        }

                        $config[$name] = $connection_config;

                    } elseif ($driver == 'pgsql') {

                        $password = $connection->password;

                        if(empty($password)) {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'port' => $connection->port,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => $password,
                                'charset' => $connection->charset,
                                'prefix' => $connection->prefix,
                                'schema' => $connection->schema,
                            );
                        }
                        else {
                            $connection_config = array(
                                'driver' => $driver,
                                'host' => $connection->host,
                                'port' => $connection->port,
                                'database' => $connection->database,
                                'username' => $connection->username,
                                'password' => Crypt::decrypt($password),
                                'charset' => $connection->charset,
                                'prefix' => $connection->prefix,
                                'schema' => $connection->schema,
                            );
                        }

                        $config[$name] = $connection_config;
                    }
                }

                /**
                 * Append a var_export of $config to the temporary file and
                 * append the semicolon.
                 *
                 * Returns the temporary filename.
                 */
                $endFile = ';';
                Storage::append($tempFileName, var_export($config, true));
                Storage::append($tempFileName, $endFile);

                return $tempFileName;

            } else {
                \error_log('Unable to create temporary file');
            }
        } else {
            \error_log('Configuration File Connection Invalid.');
            return null;
        }
    }
300617
protected function resultsToModels($connection, ResultSet $results, array $columns = [])
    {
        $models = [];

        if ($results->valid())
        {
            $resultColumns = $results->getColumns();

            foreach ($results as $result)
            {
                $attributes = $this->getProperties($resultColumns, $result, $columns);

                // Now that we have the attributes, we first check for mutations
                // and if exists, we will need to mutate the attributes accordingly.
                if ($this->shouldMutate($attributes))
                {
                    $models[] = $this->mutateToOrigin($result, $attributes);
                }
                // This is a regular record that we should deal with the normal way, creating an instance
                // of the model out of the fetched attributes.
                else
                {
                    $model = $this->model->newFromBuilder($attributes);
                    $model->setConnection($connection);
                    $models[] = $model;
                }
            }
        }

        return $models;
    }
87566
protected function getConnectionNode($node, Fluent $connection)
    {
        return $node
            ->beforeNormalization()
                ->always(function ($servers) {
                    return $this->unifyServerDeclarations($servers);
                })
            ->end()
            ->children()
                ->arrayNode('servers')
                    ->prototype('array')
                        ->children()
                            ->scalarNode('host')->defaultValue($connection->host)->end()
                            ->scalarNode('username')->defaultValue($connection->username)->end()
                            ->scalarNode('password')->defaultValue($connection->password)->end()
                            ->scalarNode('key')->defaultValue($connection->key)->end()
                            ->scalarNode('keyphrase')->defaultValue($connection->keyphrase)->end()
                            ->scalarNode('agent')->defaultTrue()->end()
                            ->scalarNode('root_directory')
                                ->info("The root directory where your applications will be deployed.\nThis path needs to start at the root, ie. start with a /")
                                ->defaultValue($connection['root'])
                            ->end()
                            ->arrayNode('roles')
                                ->info('The roles this server has, set to null if you do not use roles on your project')
                                ->defaultValue(['web', 'db'])
                                ->prototype('scalar')->end()
                            ->end()
                            ->arrayNode('config')
                                ->info('Options overrides for this server')
                                ->useAttributeAsKey('name')
                                ->prototype('array')
                                    ->prototype('variable')->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end();
    }
285131
protected function compileCreateEngine($sql, Connection $connection, Blueprint $blueprint)
    {
        if (isset($blueprint->engine)) {
            return $sql.' engine = '.$blueprint->engine;
        } elseif (! is_null($engine = $connection->getConfig('engine'))) {
            return $sql.' engine = '.$engine;
        }

        return $sql;
    }
1218129
public function getColumns($table, $connection = null)
    {
        $this->updateConnection($connection)->setUpDoctrineSchema();

        $this->validateTableName($table);

        $columns = DB::connection($this->connection)->select(
            DB::connection($this->connection)->raw("show columns from `{$table}`")
        );

        $columnData = [];

        foreach ($columns as $column) {

            $columnData[] = [
                'name'     => $column->Field,
                'type'     => $this->getColumnBaseTypeFromType($column->Type),
                'length'   => $this->getColumnLengthFromType($column->Type),
                'values'   => $this->getEnumValuesFromType($column->Type),
                'unsigned' => $this->getColumnIsNullableFromType($column->Type),
                'nullable' => ! preg_match('#^\s*no\s*$#i', $column->Null),
            ];
        }

        return $columnData;
    }
249351
protected function compileCreateEncoding( $sql, Connection $connection, Blueprint $blueprint )
	{
		if ( isset( $blueprint->charset ) )
		{
			$sql .= ' default character set ' . $blueprint->charset;
		}
		elseif ( !is_null( $charset = $connection->getConfig( 'charset' ) ) )
		{
			$sql .= ' default character set ' . $charset;
		}

		if ( isset( $blueprint->collation ) )
		{
			$sql .= ' collate ' . $blueprint->collation;
		}
		elseif ( !is_null( $collation = $connection->getConfig( 'collation' ) ) )
		{
			$sql .= ' collate ' . $collation;
		}

		return $sql;
	}