Laravel Update a Record Without Updating Timestamp Example

Hi Folks,

This article will provide some of the most important example laravel update record without update timestamp. I’m going to show you about how to update a record without updating timestamp in laravel. you will learn update without update timestamp in laravel. you can see laravel update query without update timestamp.

You can use these tips with laravel 6, laravel 7, laravel 8 and laravel 9 versions.

Sometimes, we want to update records on the database table but don’t want to update timestamps(updated_at column). Then how you can do it will laravel, we can make $model->timestamps = false; to stop updating timestamps. so let’s see the simple code:

Example:

app/Http/Controllers/DemoController.php

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;

use AppModelsPost;

class DemoController extends Controller

{

/**

* Write code on Method

*

* @return response()

*/

public function index(Request $request)

{

$post = Post::first();

/* Prevents timestamps auto-update */

$post->timestamps = false;

$post->title = "Demo Updated";

$post->save();

}

}

I hope it can help you…

Leave a Comment