In my Laravel 5 project, I would like to increase the number of views when a visitor come/refresh on the product page like:
$rds = Product::whereId($id)->first();
$rds->hits++;
$rds->save();
The problem is that the field: updated_at automatically update, which is not what I want at all because I would like to change only field: hits, not update_at field.
If I set $rds->updated_at = false; the field is updated to be '0000-00-00 00:00:0'.
Could you advise how to prevent updated_at field from automatically changing for only certain function?
Best Regards, Naren
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire