Laravel database entry DB :: table

I have this request

 DB::table('product_options')
        ->where('product_id', $id)
        ->where('size', $selected_size)
        ->update(array('stock' => WHAT TO PUT HERE));

      

In the update part where I put WHAT TO UPDATE, what should I put here to decrease the number by 1?

+3


source to share


1 answer


Use the method decrement

. http://laravel.com/docs/4.2/queries#updates



 DB::table('product_options')
        ->where('product_id', $id)
        ->where('size', $selected_size)
        ->decrement('stock');

      

+6


source







All Articles