framework icon indicating copy to clipboard operation
framework copied to clipboard

[Proposal] Common Timestamp Column names should be read from database config

Open blessingefkt opened this issue 13 years ago • 4 comments

While working on a project, I wanted all database columns to be camel case, but the created and updated columns are snake case (created_at and updated_at). I know there are constants for models that can be overrided, but I haven't found the same thing for the Schema Builder.

That being said, if the schema builder and models read the default column names from Config::get('database.columns.updated_at', UPDATED_AT), for example, then there would be more fine grained control.

blessingefkt avatar May 06 '13 05:05 blessingefkt

You're talking about the timestamps method? You can still insert timestamps manually.

$table->timestamp('createdAt');
$table->timestamp('updatedAt');

jasonlewis avatar May 06 '13 09:05 jasonlewis

I can but I felt it's a bit repetitious to add that to the schema and then have to define it again explicitly in the model code, since the name of these columns would generally be a constant thing.

blessingefkt avatar May 06 '13 17:05 blessingefkt

+1. Nice feature. And easy to implement too. I am looking forward to it.

navnit avatar May 06 '13 17:05 navnit

I don't want to add a config for this. Want to avoid config bloat. Just define the timestamps manually as mentioned.

taylorotwell avatar May 06 '13 22:05 taylorotwell