Created
August 16, 2020 03:14
-
-
Save nicolascarrascob/9e18f5742600e1c681713a3020358d9d to your computer and use it in GitHub Desktop.
Laravel Columns Info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getColumnsInfo($tableName) | |
{ | |
try { | |
$columns = DB::table('information_schema.columns') | |
->select('column_name') | |
->where('table_name', $tableName) | |
->where('column_name', '!=', 'geom') | |
->get()->toArray(); | |
foreach ($columns as $column) { | |
$column->data_type = DB::connection() | |
->getDoctrineColumn($tableName, $column->column_name) | |
->getType() | |
->getName(); | |
} | |
} catch (QueryException $e) { | |
$columns = []; | |
} | |
return $columns; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment