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
- How to remove package from 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`))
- Save or update pivot table data with additional column in Laravel
- Get previous date data in laravel
- Call to a member function pluck() on null
- Laravel route redirect not working
- In order to use the Auth::routes() method, please install the laravel/ui package
- How to disable timestamps in laravel
- Redirect to previous page or url in laravel
- Seed database using SQL file in Laravel
- How to call controller function from view in Laravel
- How to get single column value in laravel
- Drop foreign key column in Laravel using migration
- Sample .htaccess file and index.php file under public directory in laravel
- Get last week data in Laravel
- Post table seeder laravel 10
- Update record after find method in lavavel
- How to check record exist or not in relationship table
- Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
- Create project table with model and migration
- How to create projects method with belongstomany relationship in user model
- How to get database name in Laravel 9 ?
- How to customize or Change validation error messages
- After image selected get validation error in laravel
- Split an Eloquent Collection by half in Laravel