Reputation: 521
Every time I am updating a data in MYSQL, the created_at updates the same time as updated_at. I only want updated_at to be the only ones to be updating. is there anyway I can do this?
Laravel 4.2 - 5.1
here is my code in controller
public function read(){
$response = array();
$data = Docs::find(Input::get("id"));
if($data){
$data -> read = "1";
$data -> save();
$response["success"] = TRUE;
}
return Response::json($response);
}
Upvotes: 1
Views: 1043
Reputation: 6337
Since there is nothing wrong with your code, it might be a problem with how the database was setup.
A common mistake is that the created_at column, in the database, is setup to be a timestamp that automatically updates when the table data changes.
Upvotes: 1