
How to change default timestamp fields name in Laravel
How to change default timestamp fields name in Laravel
Through the use of the programming language, we will work together to solve the "How to change default timestamp fields name in Laravel" puzzle in this lesson.
Sometimes you have to change the default timestamp field name in Laravel. In case you have a non-Laravel database with created_time and updated_time columns then you can use this code snippet to solve the problem.-
Change default timestamp fields
class Post extends Model { const CREATED_AT = 'created_time'; const UPDATED_AT = 'updated_time'; }
If your timestamp columns (created_at , updated_at) are named differently, in case you are working with a non-Laravel database and you have columns created_time and updated_time in the table. You can specify them in the model, too.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Best Practices for Error Handling in Production Server Code (example code)
- How to remove P tag from CkEditor in Laravel?
- How to send email in Laravel 11
- Get latest record by created at in Laravel
- How to pass data to partial view file in laravel
- Laravel route parameter
- How to Run CRON Job on LIVE SERVER on Cpanel in Laravel Project
- How to get single column value in laravel
- How to add class to tr in table using foreach in laravel
- Extra Filter Query on Relationships in Laravel
- How to make Copy or Duplicate table row in laravel
- How to create belongstomany relation using custom name on custom pivot table
- Laravel onclick function not working
- How to print form data in laravel
- Laravel clone model
- How to check records exist in loaded relationship in Laravel blade view
- Check if Relationship Method Exists in Laravel
- FirstOrCreate() Not Inserting Model
- How to create new user without form submission in laravel
- Send OTP using textlocal api in laravel
- How to get all posts which contains comments in laravel
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- How to use bootstrap pagination in laravel 8
- Route not defined in Laravel
- How to create static page in Laravel