Fetch the column names from a model.

Submitted by orlissenberg - 9 years ago

Lists the columns on a table.

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

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