Get list and default value of columns of table with Eloquent I use the below code to get a list of columns in a table, and assign the default value to the protected var $attributes in a Laravel Model.

In this code, I use the DB function because I don't know how to achieve the same result with Eloquent.

Model.php

protected $attributes = [];

public function __construct(array $attributes = array())
{
    parent::__construct($attributes);

    $columns = DB::connection()-&gt;getDoctrineSchemaManager()-&gt;listTableColumns('mailboxes');

    foreach ($columns as $column) {
        $name = $column-&gt;getName();
        $value = $column-&gt;getDefault();
        if (!is_null($value)) {
            $this-&gt;attributes[$name] = $value;
        }
    }
}
```
If I’m fully understanding your need, the best approach would be to set the defaults at the database level. If a record is saved with a null value for that attribute, it will automatically get the default value set at the database level.  The end result is much cleaner code and no extra processing needs during data load as the default is there at rest.

In the migration, for example, $table-&gt;string(‘favorite_color’)-&gt;default(‘Blue’);  , as described at https://laravel.com/docs/master/migrations#column-modifiers

Would this solve your need? If not, it probably means your need is contextual, and that this default doesn’t always need to apply. Think critically about that context and what it represents. It might indicate a difference in data which might cause further problems down the road. 

I hope this helps!