[11.x] Add Native Timestamps method to Blueprint #52609
Closed
+13
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduced nativeTimestamps Method
This pull request introduces a new nativeTimestamps method that automatically adds timestamps to records using the database's native default settings for the current time.
Motivation
In the real world, the database is used in a wide variety of uses by a large number of applications Therefore, it is important to let the database update the respective time fields
Also, by allowing the database to handle default timestamps, we can avoid such errors sql errors and ensure smoother record insertion processes.
both of the 2 scenario will be with records of
created_at
andupdated_at
:1.
Database Migration Adjustments:
Updated database migration scripts to include
created_at
andupdated_at
columns using the timestamp method, which now optionally supports database-native defaults for timestamp fields,adhering to Laravel's philosophy of convention over configuration.
Benefits of the Change:
Reduces Boilerplate Code: Developers no longer need to manually set
created_at
andupdated_at
fields for each record insertion, simplifying the development process.Ensures Data Integrity: By using the database to manage timestamps, we guarantee accurate and consistent creation and modification times across all records, enhancing data reliability and consistency.
Improves Developer Experience: reduces the likelihood of errors and provides a more streamlined, efficient development workflow.