Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Change name of Laravel's created_at and updated_at

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 389
    Comment on it

    As we all know when we create table using php artisan and migration. Laravel create 2 column in the end of the database that column are created_at and updated_at .

    We have a situation when we want to override these two names created_at and updated_at to post_date and post_date_gmt?

    Solution :

    We can change the name of created_at and updated_at to post_date and post_date_gmt? but that will cause problems with updating timestamps unfortunately.By using the below code we can achieve change name of created_at and updated_at.

    const CREATED_AT = 'post_date';
    const UPDATED_AT = 'post_modified';
    

    then methods getCreatedAtColumn and getUpdatedAtColumn will return post_date and post_modified respectively, but won't do any harm.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: