Laravel: Disable Timestamps on Models
A few days back someone sent me a message with an issue on all the old posts on Laravel News. It wasn’t a huge bug but to fix it I had to resync all the posts from the WordPress install and as I was running through them I noticed that all the updated_at dates were then out of sync. Technically they are correct since I updated each post, but I wanted to keep the original date.
Laravel provides the ability to set this on demand and I could just include it in my command and have it ignore updating each timestamp. Here is a quick example:
[code lang=text]
$post->content = $data->content;
$post->timestamps = false; // Dont change the timestamps on save.
$post->save();
[/code]
Of course, if you don’t want timestamps at all you can disable it on the Model level through the public $timestamps = false;
property.