Posted by Arjun Arjun on Thursday 2nd April 2015, 1 minute read

Get table column names as array from Eloquent model

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

...
Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.