Simple and efficient way to manipulate your database connection scheme, whatever it may be.
gsferro/database-schema-easy is a Laravel package for simple and efficient way to manipulate your database connection scheme, whatever it may be..
It currently has 0 GitHub stars and 443 downloads on Packagist (latest version v1.1.1).
Install it with composer require gsferro/database-schema-easy.
Discover more Laravel packages by gsferro
or browse all Laravel packages to compare alternatives.
Last updated

Simple and efficient way to manipulate your database connection scheme, whatever it may be.
composer require gsferro/database-schema-easy
Package | Versão --------|----------- PHP | ^8 Laravel | ^8 Doctrine/orm | ^2.14
Instancie o serviço
$schema = new DatabaseSchemaEasy(string $table, string $connection = null);
Facade
$schema = dbschemaeasy(string $table)
hasTable(): bool: Verifica se a table exists
$schema->hasTable();
# true
getColumnListing(bool $includePrimaryKeys = true, bool $includeTimestamps = false): array : Retorna todas as colunas da table
$schema->getColumnListing();
/*
[
"id",
"uuid",
"pedido_status_id",
]
*/
hasColumn(string $column): bool: Verifica se a coluna exists
$schema->hasColumn('id');
# true
hasColumns(array $columns): bool:Verifica se as colunas exists
$schema->hasColumns(['id', 'uuid']);
# true
hasColumnsTimestamps(): bool: Verifica se a coluna exists
$schema->hasColumnsTimestamps();
# true
getTypeFromColumns(array $columns): array: Pega todos os tipos das colunas
$schema->getTypeFromColumns(['id', 'uuid']);
/*
[
"id" => "integer",
"uuid" => "guid",
]
*/
getColumnType(string $column): string:Retorna o type da colunas
$schema->getColumnType('id');
# "integer"
getDoctrineColumn(string $column): array:Retorna todas as informações da colunas
$schema->getDoctrineColumn('id');
/*
[
"name" => "id",
"type" => Doctrine\DBAL\Types\IntegerType {#4751},
"default" => null,
"notnull" => true,
"length" => null,
"precision" => 10,
"scale" => 0,
"fixed" => false,
"unsigned" => false,
"autoincrement" => true,
"columnDefinition" => null,
"comment" => null,
"primary_key" => true,
]
*/
isPrimaryKey(string $column): bool:Verifica se a coluna é pk
$schema->isPrimaryKey('id');
# true
primaryKeys(): array:Retorna as chaves pks
$schema->primaryKeys();
/*
[
"id",
]
*/
hasModelWithTableName(string $table = null): bool|string:Verifica se a table já existe model eloquent criada
$schema->hasModelWithTableName();
# "App\Models\Pedidos"
$schema->hasModelWithTableName('abc');
# false
getAllTables(): array: Todas as tabelas da conexão
$schema->getAllTables();
/*
[
'pedidos',
'pedido_status,
...
]
*/
hasForeinsKey(string $column, bool $fromStubReplace = false): bool|array: Verifica se a coluna é uma foreing key e devolve os dados do relacionamento
$schema->hasForeinsKey('pedido_status_id');
/*
[
"table" => "pedido_status",
"tableCamel" => Illuminate\Support\Stringable {#5069
value: "pedidoStatus",
},
"related" => Illuminate\Support\Stringable {#5068
value: "",
},
"relatedInstance" => false,
"foreignKey" => "pedido_status_id",
"ownerKey" => "id",
]
*/