spacedog4
9 months ago

A simpler way to get all attributes from a model including timestamp

Posted 9 months ago by spacedog4

I need to get all my model's table fields so I can remap it to another name

I tryied to use both codes

\Schema::getColumnListing($model->getTable());

// or

$model->getAttributes();

Both of then don't return me the created_at and updated_at fields

I need a simpler way to do this

public function($model) 
{
    return array_merge(array_keys($model->getAttributes()), $model->getDates());
}

Please sign in or create an account to participate in this conversation.