Home > Backend Development > PHP Tutorial > Laravel5.2 uses update to update data, why is created_at also updated?

Laravel5.2 uses update to update data, why is created_at also updated?

WBOY
Release: 2016-07-06 13:52:42
Original
1911 people have browsed it

Execute function

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

User.php

<code>    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',
    ];
</code>
Copy after login
Copy after login

It is a very ordinary update, the user data is already available.

6.24 update, I set the extra value of the crated_at field in the user table to null, and it seems to be fine. Before, it was on update CURRENT_TIMESTAMP

Reply content:

Execute function

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

User.php

<code>    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',
    ];
</code>
Copy after login
Copy after login

It is a very ordinary update, the user data is already available.

6.24 update, I set the extra value of the crated_at field in the user table to null, and it seems to be fine. Before, it was on update CURRENT_TIMESTAMP

It seems that other people have encountered this problem: https://github.com/laravel/framework/issues/11518

Try creating migration when

<code class="php">$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->useCurrent();</code>
Copy after login

or

<code class="php">$table->nullableTimestamps();</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template