How to Update a Record Without Timestamp in Laravel
In this tutorial, we will learn How to Update a Record Without Timestamp in Laravel. Sometimes, we need to update records on the database table but we don’t want to update timestamps(updated_at column). So, how you can do it in Laravel, we can make $model->timestamps = false; to stop updating timestamps. I will provide some of the most important examples of Laravel update records without timestamps. I’m showing you how to update a record without a timestamp in the Laravel application. In this post, you will learn to update without updating timestamps in Laravel. And you can see the update query without an update timestamp.
Example
<?php
#app/Http/Controllers/HomeController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
class HomeController extends Controller {
/**
* Write code on Method
*
* @return response()
*/
public function index(Request $request)
{
$user = User::find(1);
$user->timestamps = false;
$user->company = "admins update";
$user->update();
}
}