Skip to content

Instantly share code, notes, and snippets.

@keithics
Created August 9, 2013 00:52
Show Gist options
  • Save keithics/6190293 to your computer and use it in GitHub Desktop.
Save keithics/6190293 to your computer and use it in GitHub Desktop.
Get column names in Laravel 4
<?php
class BaseModel extends Eloquent {
public function columns(){
$table = $this->getTable();
return DB::select(" SHOW COLUMNS FROM ".$table);
}
}
// other model
class OtherModel extends BaseModel{
}
// controller
$table = new \OtherModel;
dd($table->columns());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment