Get table column names as array from Eloquent model

Submitted by Landish - 2 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());
comments powered by Disqus

Ads cover the costs of maintaining Laravel-tricks