Returns the list of tables in the currently-connected database.

@param string $model The fully-name-spaced class name of the model object making the request.
@return array Returns an array of sources to which models can connect.
@filter
513057
public function sources($model = null) {
		$params = compact('model');

		return Filters::run($this, __FUNCTION__, $params, function($params) {
			$schema = $this->connection->quote($this->_config['schema']);

			$sql  = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables";
			$sql .= " WHERE table_schema = {$schema}";

			if (!$result = $this->_execute($sql)) {
				return null;
			}
			$sources = [];

			foreach ($result as $row) {
				$sources[] = $row[0];
			}
			return $sources;
		});
	}
359676
public function getModelArray(Model $model)
    {
        $result = [];
        foreach ($model->getAttributes() as $key => $value) {
            $result[] = ['type' => 'text', 'name' => $key, 'key' => $key.' :', 'value' => $value];
        }
        unset($result[0]);

        return $result;
    }
240162
public function table($model)
    {
        return $this->table->of('control.roles', function (TableGrid $table) use ($model) {
            // attach Model and set pagination option to true.
            $table->with($model)->paginate(true);

            $table->sortable();
            $table->searchable(['name']);

            $table->layout('orchestra/foundation::components.table');

            // Add columns.
            $table->column(trans('orchestra/foundation::label.name'), 'name');
        });
    }
291346
protected function scopedAttributes( $model )
	{
		$keys = $this->model->getScopedColumns();

		if ( count( $keys ) == 0 )
			return [];

		$values = array_map( function ( $column ) use ( $model )
		{
			return $model->getAttribute( $column );
		}, $keys );

		return array_combine( $keys, $values );
	}
615161
protected function determineModelReferenceSource(Model $model)
    {
        $source = $this->getReferenceSource($model);

        // If we have no source to fall back on at all, use the model key
        if ( ! $source) {
            $source = $model->getKeyName();
        }

        return $source;
    }
1003968
public function children( $model )
	{
		$query = $this->model->newQuery();

		$query->where( $this->model->getQualifiedParentColumnName(), '=', $model->getKey() );

		// We must also add the scoped column values to the query to compute valid
		// left and right indexes.
		foreach ( $this->scopedAttributes( $model ) as $fld => $value )
			$query->where( $this->qualify( $fld ), '=', $value );

		$query->orderBy( $this->model->getQualifiedLeftColumnName() );
		$query->orderBy( $this->model->getQualifiedRightColumnName() );
		$query->orderBy( $this->model->getQualifiedKeyName() );

		return $query->get();
	}
104031
public function getCount(Model $model) {
        return $model->find('count', array(
            'cache' => $model->alias . '::getCount',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
1090328
protected function getAttributes($model)
    {
        $attributes = $model->attributesToArray();
        foreach( $this->immutableAttributes as $attribute ) {
            unset( $attributes[ $attribute] );
        }

        return $attributes;
    }
848929
protected function getModelPermissions($model)
    {
        $tree = $this->treeBuilder->getTree();
        $psrClass = '';
        if (is_string($model)) {
            $psrClass = $model;
        } elseif (is_object($model)) {
            $psrClass = get_class($model);
        }

        if (!empty($tree['models']) && array_key_exists($psrClass, $tree['models'])) {
            return $tree['models'][$psrClass];
        }

        return [];
    }
1367823
protected function getPropertiesFromTable($model)
    {
        $table = $model->getConnection()->getTablePrefix() . $model->getTable();
        $schema = $model->getConnection()->getDoctrineSchemaManager($table);
        $databasePlatform = $schema->getDatabasePlatform();
        $databasePlatform->registerDoctrineTypeMapping('enum', 'string');

        $platformName = $databasePlatform->getName();
        $customTypes = $this->laravel['config']->get("ide-helper.custom_db_types.{$platformName}", array());
        foreach ($customTypes as $yourTypeName => $doctrineTypeName) {
            $databasePlatform->registerDoctrineTypeMapping($yourTypeName, $doctrineTypeName);
        }

        $database = null;
        if (strpos($table, '.')) {
            list($database, $table) = explode('.', $table);
        }

        $columns = $schema->listTableColumns($table, $database);

        if ($columns) {
            foreach ($columns as $column) {
                $name = $column->getName();
                if (in_array($name, $model->getDates())) {
                    $type = '\Illuminate\Support\Carbon';
                } else {
                    $type = $column->getType()->getName();
                    switch ($type) {
                        case 'string':
                        case 'text':
                        case 'date':
                        case 'time':
                        case 'guid':
                        case 'datetimetz':
                        case 'datetime':
                            $type = 'string';
                            break;
                        case 'integer':
                        case 'bigint':
                        case 'smallint':
                            $type = 'integer';
                            break;
                        case 'boolean':
                            switch (config('database.default')) {
                                case 'sqlite':
                                case 'mysql':
                                    $type = 'integer';
                                    break;
                                default:
                                    $type = 'boolean';
                                    break;
                            }
                            break;
                        case 'decimal':
                        case 'float':
                            $type = 'float';
                            break;
                        default:
                            $type = 'mixed';
                            break;
                    }
                }

                $comment = $column->getComment();
                if (!$column->getNotnull()) {
                    $this->nullableColumns[$name] = true;
                }
                $this->setProperty($name, $type, true, true, $comment, !$column->getNotnull());
                if ($this->write_model_magic_where) {
                    $this->setMethod(
                        Str::camel("where_" . $name),
                        '\Illuminate\Database\Eloquent\Builder|\\' . get_class($model),
                        array('$value')
                    );
                }
            }
        }
    }
105772
public function getExtraRelations($models) {
        if (!$this->relationsParser){
            return [];
        }
        $relationsLeft = $this->relationsParser->getRelationsToBeSelectedSeparately();
        foreach ($relationsLeft as $path => $details){
            $this->relationsParser->getChildrenForModels($models, $path, $details, $this->fields);
        }

    }
932375
public function getTableName($model = null)
    {
        $model = $model ?? $this->model;

        if ($model instanceof Model) {
            return $model->getTable();
        } elseif ($model instanceof EloquentBuilder) {
            return $model->getModel()->getTable();
        }

        return $model->from;
    }
662374
private function buildRelationshipAttributes($model)
    {
        $result = [];

        foreach ($model->getSearchRelationships() as $method) {
            if (!method_exists($model, $method)) {
                continue;
            }

            $relation = self::getRelation($model->$method());
            $this->relationships[$method] = $relation;

            self::buildCastedAttributes($relation['model'], $result, $method);
            self::buildSearchAttributes($relation['model'], $result, $method);
        }

        return $result;
    }
1261576
private function getModelAttributes(&$model)
	{
		$response 	= array();
		$reflection = new ReflectionClass($model);
		$properties = $reflection->getProperties(ReflectionProperty::IS_PROTECTED);

		foreach ($properties as $property)
			$response[$property->name] = $model[$property->name];

		return $response;
	}
383107
public function getAll(Model $model) {
        return $model->find('all', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC'),
            'cache' => $model->alias . '::getAll',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
700442
protected function setColumns($model)
    {
        $schema = $model->getConnection()->getDoctrineSchemaManager();
        $platform = $schema->getDatabasePlatform();

        // Prevents a DBALException if the table contains an enum.
        $platform->registerDoctrineTypeMapping('enum', 'string');

        list($table, $database) = $this->getTableAndDatabase($model);

        $this->columns = $model->getConnection()->getDoctrineConnection()->fetchAll(
            $platform->getListTableColumnsSQL($table, $database)
        );

        $this->rejectVirtualColumns();

        $columns = $this->columns;
        $this->columns = call_user_func(\Closure::bind(function () use ($table, $database, $columns) {
            return $this->_getPortableTableColumnList($table, $database, $columns);
        }, $schema, $schema));

        return $this->unquoteColumnNames($platform->getIdentifierQuoteCharacter());
    }
449194
public function scaffoldViewColumns(Model $model)
    {
        $items = new Mutable();

        $attributes = \admin\helpers\eloquent_attributes($model);

        foreach ($attributes as $key => $value) {
            $items->push($key);
        }

        return $items->build(
            new GridDecorator($model)
        );
    }