title: Laravel cant add quantity using increment method with modal and ajax
body: <p>Im making an inventory system with laravel and I want to add a quantity in my product after I registered it, unfortunately I cant update or add the quantity using the <code>increment</code> method in laravel. Also, Im using a modal and ajax in storing the values. Can someone know what is the problem with my codes?</p>
  
  <p>Error code
  <a href="https://i.stack.imgur.com/FC9xj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FC9xj.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/OpJ5h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OpJ5h.png" alt="enter image description here"></a></p>
  
  <p>Controller</p>
  
  <pre><code>
    public function stockIn(Request $request, $id){
  
  
          $product = Product::findOrFail($id);
          $data = $request-&gt;all();
  
          $product['quantity'] = ($data-&gt;increment(['quantity']));
  
  
          $product-&gt;save();
  
          return response()-&gt;json($data);
  
      }
  </code></pre>
  
  <p>Modal</p>
  
  <pre><code>
                               {{-- add qty --}}
              &lt;div class="modal fade" id="exampleModalCenter_qty" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true"&gt;
                      &lt;div class="modal-dialog modal-dialog-centered" role="document"&gt;
                        &lt;div class="modal-content"&gt;
                          &lt;div class="modal-header"&gt;
                            &lt;h5 class="modal-title" id="exampleModalCenterTitle"&gt;Edit Product&lt;/h5&gt;
                            &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                              &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
                            &lt;/button&gt;
                          &lt;/div&gt;
                          &lt;div class="modal-body"&gt;
                          &lt;p style="font-weight: bold;"&gt;Enter Quantity &lt;/p&gt;
                            &lt;input    type="text" class="form-control" id="add_quantity"/&gt;
                          &lt;div class="modal-footer"&gt;
                            &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt;
                            &lt;button type="button" class="btn btn-success" id="stockIn"&gt;Update&lt;/button&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  {{-- add qty --}}
  </code></pre>
  
  <p>ajax script</p>
  
  <pre><code>  $('.addQty').on('click', function(e) {
                  const myValue = $(this).attr('id');
                  let qty = $(this).closest('tr').find('td:eq(5)').text();
  
                  $('#add_quantity').val(qty);
  
  
                   $('#stockIn').click(function(e) {
                      e.preventDefault();
  
                      let quantity = $('#add_quantity').val();
  
                      $.ajaxSetup({
                      headers:{
                              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                          }
                      });
  
                      $.ajax({
                          url: "{{ url('/addStocks') }}" + '/'+ myValue,
                          method: 'put',
                          data: {
                              name: quantity
                          },
                          success: function(res){
                              console.log(res);
                               window.location.href='{{route("product.index")}}';
                          }
                      })
  
                   });
                });
  </code></pre>
  
  <p>route</p>
  
  <pre><code>//addQty
  Route::put('/addStocks', 'ProductsController@stockIn');
  </code></pre>