title: Trying to acess data of an object, says inaccessible
body: <p>i am trying to access property of object but while it shows the data is object but when i try to access the property it gives error 'Use of undefined constant 'id';
  the code is ;</p>
  <pre><code>function returnProducts(Request $request,$id){
      $user = Auth::user();
      if($user-&gt;hasRole(['customer','bos_customer','admin','vendor','business_owner',
          'merchant','city_manager','city_order_manager'])){
          $sale = Sale::find($id);
          $saleDetail=$sale-&gt;saleDetails;
          $num=count($saleDetail);         
        return $request-&gt;product_ids[id];
  </code></pre>
  <p><a href="https://i.stack.imgur.com/4SweT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4SweT.png" alt="enter image description here" /></a></p>
  <p>the input recieved from the front-end is called from</p>
  <pre><code>return $request;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/uZovD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uZovD.png" alt="enter image description here" /></a></p>
  <p>how can i access the object property i tried accesing it but cannot wrap my head around the problem  i am facing</p>