Get table column names as array from Eloquent model

Submitted by Landish - 9 years ago

If for some reason, you need to get the array of eloquent model's table column names, here's one way to do it:

class Model extends Eloquent {
    
    public function getTableColumns() {
        return $this->getConnection()->getSchemaBuilder()->getColumnListing($this->getTable());
    }
    
}