
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 display HTML tags In Laravel blade
- Retrieve count of nested relationship data in Laravel
- Property [user] does not exist on this collection instance
- Laravel onclick function not working
- Undefined property: stdClass::$title
- How to pass query string with pagination in laravel
- How to get laravel errors folder in views directory in laravel
- How to insert ckeditor data into database in Laravel?
- Check if Relationship Method Exists in Laravel
- Update existing pivot table data in laravel
- Redirect to another view from controller in laravel
- Cannot end a section without first starting one
- Drop foreign key column in Laravel using migration
- How to upload files to amazon s3 bucket using Laravel
- Laravel insert query not working
- Redirect from www to non www in laravel using htaccess
- How to get data from two tables in laravel
- How to call controller function from view in Laravel
- Remove public from url in laravel project
- Laravel get single row by id
- SQLSTATE[42000]: Syntax error or access violation: 1055
- Target class [App\Http\Controllers\Auth\Request] does not exist.
- How to use more than one query scope in Laravel
- Laravel URL validation not working
- Get duplicate records in laravel