
How to change default timestamp fields name in Laravel
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.
Answers 1
-
Change default timestamp fields
class Post extends Model { const CREATED_AT = 'created_time'; const UPDATED_AT = 'updated_time'; }
0If 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.
Random Code Snippet Queries: Laravel
- Extra Filter Query on Relationships in Laravel
- How to customize pagination view in laravel
- How to insert dynamic value to additional column in pivot table in laravel
- Class 'App\Rules\Hash' not found in Laravel
- How to get list of all views file in laravel
- How to restore multiple records after soft-deletes in Laravel
- OrderBy on Eloquent relationships method in Laravel
- How to get laravel errors folder in views directory in laravel
- Print last executed query in laravel
- How to call controller function from view in Laravel
- Print query in laravel
- How to implement toggleLike() method in Overtrue\LaravelLike laravel package
- Delete records with relationship in laravel
- Use of undefined constant laravel
- How to get the id of last record from collection object in laravel view
- Page loader in laravel
- Display success message in laravel
- The Pusher library requires the PHP cURL module. Please ensure it is installed
- How to get column names from table in Laravel
- Get comma separated email from input array
- How to display user profile after login in laravel
- In order to use the Auth::routes() method, please install the laravel/ui package
- How to check if user has created any post or not in laravel
- How to get path from current URL in Laravel
- Laravel 5.4 save data to database