-1

So I'm importing a Sequelize/Postgres database into a brand new Laravel app. Thing is, its columns are all weird. It uses createdAt and updatedAt when Laravel, of course, is created_at and updated_at.

Without needing to update the column names, is there a way I can reference created_at as the column name createdAt? I know you can reference table names with new names such as public $table = 'newTableName';

test
  • 17,706
  • 64
  • 171
  • 244
  • it seems there are different ways to configure naming https://laracasts.com/discuss/channels/eloquent/why-are-created-at-and-updated-at-constants-in-the-eloquent-model-class – skyboyer Jun 17 '18 at 22:37
  • Possible duplicate of [Change name of Laravel's created\_at and updated\_at](https://stackoverflow.com/questions/24404474/change-name-of-laravels-created-at-and-updated-at) – ggdx Jun 17 '18 at 22:43

1 Answers1

2

"If you need to customize the names of the columns used to store the timestamps, you may set the CREATED_AT and UPDATED_AT constants in your model:"

class Flight extends Model
{
    const CREATED_AT = 'creation_date';
    const UPDATED_AT = 'last_update';
}

Laravel Docs - 5.6 - Eloquent - Model Conventions

lagbox
  • 48,571
  • 8
  • 72
  • 83