vendredi 29 avril 2016

How update an field by adding one itself in laravel elequent?

When user booking an offer, I want to decrease availability field in the table by one. For this,In MySQL, I can run following query

UPDATE table SET field = field - 1 WHERE id = $number

But This how can I implement in Laravel eloquent update Query method.

 $offer = Offer::find(1);
 $offer->availability = $offer->availability+1;
 $offer->save();

I know this method but I want to get equivalent to above MySQL query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire