laravel5.2 Update data using update, why is Created_at also updated?

Source: Internet
Author: User
Execute function

public function registerStore(Requests\RegisterRequest $request){        $user=User::user();        $res=$user->update($request->all());        return redirect('/');    }

user.php

    protected $fillable = [        'name', 'email', 'password', 'openid','user_id','truename','tel','card','bank_name','bank_branch'    ];    /**     * The attributes excluded from the model's JSON form.     *     * @var array     */    protected $hidden = [        'password', 'remember_token',    ];

is a very common update, the user data already has.

6.24 Update, I say the extra value of the Crated_at field in the user table is set to NULL, which seems to be good, before the on update current_timestamp

Reply content:

Execute function

public function registerStore(Requests\RegisterRequest $request){        $user=User::user();        $res=$user->update($request->all());        return redirect('/');    }

user.php

    protected $fillable = [        'name', 'email', 'password', 'openid','user_id','truename','tel','card','bank_name','bank_branch'    ];    /**     * The attributes excluded from the model's JSON form.     *     * @var array     */    protected $hidden = [        'password', 'remember_token',    ];

is a very common update, the user data already has.

6.24 Update, I say the extra value of the Crated_at field in the user table is set to NULL, which seems to be good, before the on update current_timestamp

It seems like someone else has come across this problem: https://github.com/laravel/framework/issues/11518

Try to look at the establishment migration

$table->timestamp('created_at')->useCurrent();$table->timestamp('updated_at')->useCurrent();

Or

$table->nullableTimestamps();
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.