Created
August 9, 2013 00:52
-
-
Save keithics/6190293 to your computer and use it in GitHub Desktop.
Get column names in Laravel 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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