Fetch the column names from a model.

Submitted by orlissenberg - 3 years ago

Lists the columns on a table.

$columns = \Schema::connection('databaseName')->getColumnListing('tableName');

$columns = ExampleEloquentModel::getModel()->getConnection()->getSchemaBuilder()->getColumnListing(ExampleEloquentModel::getModel()->getTable());

Ads cover the costs of maintaining Laravel-tricks

comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks