Eloquent model not updating updated_at timestamp

后端 未结 5 644
無奈伤痛
無奈伤痛 2021-02-12 14:52

I\'m using Laravel 5.1. To make it simple, I have the following code

Migration:

Schema::create(\'sitemap_data\', function (Blueprint $table) {
    // Pri         


        
5条回答
  •  清歌不尽
    2021-02-12 15:06

    It is possible actually:

    $model->updated_at = Carbon::now();
    $model->save(['timestamps' => FALSE]);
    

    That will properly save the updated_at to now. If you're not sure if any of the model's columns have changed, but you do want to update the updated_at regardless - this is the way to go.

提交回复
热议问题