Disable Laravel's Eloquent timestamps

后端 未结 10 1501
余生分开走
余生分开走 2020-12-04 08:54

I\'m in the process of converting one of our web applications from CodeIgniter to Laravel. However at this moment we don\'t want to add the updated_at / c

10条回答
  •  余生分开走
    2020-12-04 09:29

    You can temporarily disable timestamps

    $timestamps = $user->timestamps;
    $user->timestamps=false;   // avoid view updating the timestamp
    
    $user->last_logged_in_at = now();
    $user->save();
    
    $user->timestamps=$timestamps;   // restore timestamps
    

提交回复
热议问题