
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
- Insert dummy data in users table Laravel
- Count all and get 10 records after where condition in laravel
- The use statement with non-compound name 'DB' has no effect
- Store logged in user details in session and display in view in laravel
- How to get all posts which contains comments in laravel
- Delete records with relationship in laravel
- After image selected get validation error in laravel
- How to get the id of last record from collection object in laravel view
- Pass value from controller to model in laravel
- Laravel form request validation
- How to customize or Change validation error messages
- Array to string conversion laravel Controller
- Target class [admin] does not exist.
- Submit form without CSRF token in Laravel
- SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'posts_user_id_foreign'; check that column/key exists
- Method Illuminate\Http\Request::validated does not exist
- How to validate URL with https using regex in laravel
- Target class [HomeController] does not exist
- How to get route name on visit URL in laravel
- Delete file from amazon s3 bucket using Laravel
- Insert Comma Separated Values in laravel
- If no route matched route::fallback in laravel
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.post_id' in 'where clause
- How to insert value to additional columns in pivot table in laravel
- Laravel pagination links with query string