I've tried this code:
//controller
$model = new Mymodel;
$table = $model->getTable();
$columns = Schema::getColumnListing($table);
//view.blade.php
{{print_r($columns)}}
but the result only give this output: Array ( [0] => * ) 1
More Information:
I need to connect to SQL Server database with Forticlient VPN. I think it shouldn't be the problem. But, tell if there's something I've missed.
CodePudding user response:
After struggling looking for any answer, and looking for answer generally about how to get the column name straight from SSMS, I've made my temporary own solution. Here's the code:
$model = new Mymodel;
$table = $model->getTable();
$schema = DB::table('INFORMATION_SCHEMA.COLUMNS')
->select('COLUMN_NAME')
->where("TABLE_NAME", $table)
->get();
My own answer is only improvement from the base query to get column name straight from the SSMS, here the query:
select COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'mytable_name'