title: How to make this increment code works in laravel command file schedule
body: <p>I'm updating those orders status "New" to "Cancel" using a command schuduler and running it every minute, the update function is working, but the problem is each time you update the New to Cancel, I have another condition to increment or add back the quantity of the ordered products back to the products stock</p>
  
  <pre><code>    $getNeworders = Order::with('products')
          -&gt;where('order_status', '=' ,'New')
          -&gt;whereDate('created_at' , '&lt;' ,Carbon::now()-&gt;subMinutes(1440))-&gt;get();
      //1440minutes in 24hrs
  
      foreach($getNeworders as $try) {
          $gettheid= $try-&gt;id;
             Order::where(['id'=&gt;$gettheid])-&gt;update(['order_status' =&gt;'Cancelled']);
  
      }
  
      foreach($getNeworders as $increments){
      foreach($increments-&gt;product() as $incrementt)
          $idd= $incrementt-&gt;product_id;
          $qty= $incrementt-&gt;pivot()-&gt;quantity;
  
          Product::where(['id' =&gt; $idd])-&gt;decrement(['stock' =&gt; $qty]);
  </code></pre>
  
  <p>// the update is working fine, but the increment statement below is not working</p>