laravel get column field name code example
Example 1: laravel get list of columns in a table
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
public function getTableColumns($table)
{
return DB::getSchemaBuilder()->getColumnListing($table);
return Schema::getColumnListing($table);
}
Example 2: laravel get column field name
composer require doctrine/dbal
$columnType = DB::getSchemaBuilder()->getColumnType($tableName, $colName)
$columnType = DB::getSchemaBuilder()->getColumnType('user', 'age')