Customisable timestamp fields
See original GitHub issueTo ease migration the project I’m working on uses created and modified field names instead of created_at and modified_at fields.
In PanelTraits/Autoset.php getDbColumnNames, the fields are hard coded as created_at and modified_at:
return array_values(array_diff($columns, [$this->model->getKeyName(), 'created_at', 'updated_at', 'deleted_at']));
This can be changed to:
return array_values(array_diff($columns, [$this->model->getKeyName(), $this->model::CREATED_AT, $this->model::UPDATED_AT, 'deleted_at']));
This will allow users to define their own timestamp fields, rather than assuming the defaults which may not be the case
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to use a custom timestamp column - ksqlDB Documentation
Use the timestamp attribute within events to do time-related processing with ksqlDB.
Read more >Timestamps, Time Zones, Time Ranges, and Date Formats
If the timestamp format is in epoch time, enter "epoch" in the Format field. Your custom timestamp format must follow our supported timestamp...
Read more >How to create a time stamp custom field. - LeadsHook
How to create a time stamp custom field. · Simply create a text field called 'timestamp' · And then copy/paste this code into...
Read more >Add a timestamp (date & time) custom field type
Description. We want to be able to register in a custom field the date and time of some events that are not in...
Read more >Sharepoint Custom List with TimeStamp Field - Stack Overflow
I need a TimeStamp Field, but the only available type, by default, is DateTime. Any help? sharepoint · Share.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
😃) well this got a little steamy. Guys, please, relax. We all want the same thing here - Backpack to be as useful as possible, for all of us. It’s normal to have different opinions, but in the end - we want the same thing.
@indra1 - in this case I think @Spodnet is right.
@Spodnet - I wasn’t aware of those constants - I never used different column names for created_at and updated_at in Laravel. But if Laravel supports changing them, so should Backpack, I agree. And it’s such a simple change, and backwards-compatible. No reason not to do it. It’s done, just pushed it on the
dev
branch. It will be available in the next patch release (today or tomorrow), bundled with other backward-compatible updates.Cheers!
It’s a 15 second change, to keep within the eloquent standard, the standard method for finding what those fields are named, should be to call the methods or use the constant much the same as you do for primary key name, otherwise why not hard code ‘id’ which by your argument is “standard”
The next developer or other developers in the team, can quite easily see the const definition in the models (all several hundred of them) at the top of the model class, and they can refer to the documentation for the project, so wouldn’t spend hours looking at code.
A crud library needs to be as flexible as possible, I see this as an improvement by keeping to standard methods, and would not cause unexpected issues if another user comes along using different field names for whatever reason.