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:

$post->content = $data->content;
$post->timestamps = false; // Dont change the timestamps on save.

Of course, if you don’t want timestamps at all you can disable it on the Model level through the public $timestamps = false; property.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s