title: Laravel get column as array list
body: <p>How can I iterate a certain column when make a query using Eloquent laravel orm.</p>
  
  <pre><code>public function getProductAPI(Request $request)
      {
  
          $id = JWTAuth::parseToken()-&gt;authenticate()-&gt;id;
  
          $product = Product::where('user_id',$id)-&gt;get()-&gt;toArray();
  
          foreach ($product-&gt;description as $desc) { 
  
              dd($desc);
          }
          dd($product);
  
  
          return response()-&gt;json($product);
      }
  </code></pre>
  
  <p>Both <code>$product-&gt;description</code> and <code>$product["description"]</code> returning an error of <code>Undefined index: description</code> and <code>Trying to get property of non-object</code></p>
  
  <h2>EDIT:</h2>
  
  <p>This are the output of dd($product):</p>
  
  <pre><code> array:2 [
        0 =&gt; array:15 [
          "id" =&gt; 1
          "user_id" =&gt; 24
          "title" =&gt; "Langkawi"
          "description" =&gt; "Lorem ipsum WTF???"
          "category" =&gt; 1
          "city" =&gt; 2
          "image_url" =&gt; "https://qwert.s3-us-west-2.amazonaws.com/default/no-image.png"
          "price" =&gt; "30"
          "location" =&gt; "Langkawi"
          "discount" =&gt; "10%"
          "start_date" =&gt; "0000-00-00"
          "end_date" =&gt; "0000-00-00"
  
        ]
        1 =&gt; array:15 [
          "id" =&gt; 6
          "user_id" =&gt; 24
          "title" =&gt; "ADVANCE AND DEFENSIVE DRIVING COURSE # SHAH ALAM"
          "description" =&gt; "Lorem ipsum WTF??? V2"
          "category" =&gt; 0
          "city" =&gt; 0
          "image_url" =&gt; "https://qwert.s3-us-west-2.amazonaws.com/default/no-image.png"
          "price" =&gt; ""
          "location" =&gt; ""
          "discount" =&gt; ""
          "start_date" =&gt; "0000-00-00"
          "end_date" =&gt; "0000-00-00"
  
        ]
      ]
  </code></pre>
  
  <p>I cant specifically get a column for modification. </p>
  
  <p>Thanks!!</p>