06-Feb-2023
.
Admin
Hi dev,
The most significant examples of Laravel update records without update timestamps are provided in this article. I'll demonstrate how to change a record in Laravel without altering the timestamp. In Laravel, you will learn how to update without using a timestamp. Laravel update query without update timestamp is visible.
On sometimes, we wish to make changes to records in a database table without making changes to the timestamps (updated at column). Then, to stop updating timestamps, we may make $model->timestamps = false; in Laravel. So let's look at the basic code:
Example:
app/Http/Controllers/DemoController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Post;
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...
#Laravel