samedi 27 août 2016

Laravel 5: Update record without changing current date/time value of updated_at field

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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2bsyZ23
via IFTTT

Aucun commentaire:

Enregistrer un commentaire