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
- Json encode method in laravel
- How to get records in random order in laravel
- Get id of last inserted record in laravel
- Get posts belongs to a specific user in Laravel
- How to create event and listener in laravel ?
- Docker important commands to run laravel application with docker
- How to customize pagination view in laravel
- Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table (SQL: alter table `users` add constraint `users_role_id_foreign` foreign key (`role_id`) references `roles` (`id`))
- Update if exist else insert new record in laravel
- Symlink(): No such file or directory
- How to update record after save method in Laravel
- Laravel route parameter
- How to upload files to amazon s3 bucket using Laravel
- Route prefix with auth middleware in laravel
- Declaration of App\Models\Post::sluggable() must be compatible with Cviebrock\EloquentSluggable\Sluggable
- Laravel delete all rows older than 30 days
- Get current month records in laravel 7/8
- How to insert value to additional columns in pivot table in laravel
- Laravel get count with where condition
- How to generate .env file for laravel?
- How to get laravel errors folder in views directory in laravel
- Create record with unique slug in laravel
- How to get only time from created_at in laravel
- How to pass two variables in HREF in laravel
- How to add dynamic page title in Laravel view