title: How to get an item from a collection in Laravel 5?
body: <p>I'm new to <code>Laravel</code> and I cannot figure out how to get the value of an item from within the returned collection. Here is my code:</p>
  
  <pre><code>$aircraft = Aircraft::join('pams_shared.shared_aircraft', 'aircraft.shared_aircraft_id', '=', 'pams_shared.shared_aircraft.shared_aircraft_id')
          -&gt;select('aircraft.*', 'shared_aircraft.*')
          -&gt;where('aircraft.owner_id',Auth::user()-&gt;owner_id)
          -&gt;where('registration',$reg)
          -&gt;get();
  </code></pre>
  
  <p>I want to get the value from <code>aircraft.aircraft_id</code> but that's where I get stuck. I've tried:</p>
  
  <pre><code>    $id = $aircraft-&gt;aircraft_id;
  </code></pre>
  
  <p>I've tried:</p>
  
  <pre><code>    $id = $aircraft-&gt;aircraft.aircraft_id;
  </code></pre>
  
  <p>I've also tried:</p>
  
  <pre><code>    $id = array_get($aircraft, 'aircraft_id');
  </code></pre>
  
  <p>But I'm getting <code>null</code> as a value. When I perform either a <code>var_dump($aircraft)</code> or <code>dd($aircraft)</code> I'm able to confirm that the data is there.</p>
  
  <p>In my view I am able to access the value by looping through, but I need this data in my controller to perform a second query on another table.</p>
  
  <p>Hope that makes sense. Cheers.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>When running <code>dd($aircraft);</code> I get this:</p>
  
  <pre><code>Collection {#239 ▼
  #items: array:1 [▼
      0 =&gt; Aircraft {#240 ▼
              #fillable: array:8 [▶]
              #table: "aircraft"
              #primaryKey: "aircraft_id"
              #connection: null
              #perPage: 15
              +incrementing: true
              +timestamps: true
              #attributes: array:16 [▼
                  "aircraft_id" =&gt; 5
                  "owner_id" =&gt; 2
                  "shared_aircraft_id" =&gt; 67443
                  "year" =&gt; 2012
                  "serial_number" =&gt; "C127RG3"
                  "registration" =&gt; "C-SMTH"
                  "created_by" =&gt; 2
                  "modified_by" =&gt; 2
                  "created_at" =&gt; "0000-00-00 00:00:00"
                  "updated_at" =&gt; "0000-00-00 00:00:00"
                  "aircraft_code" =&gt; "2072438"
                  "aircraft_mfr" =&gt; "CESSNA"
                  "aircraft_model" =&gt; "172RG"
                  "aircraft_type" =&gt; 4
                  "aircraft_eng" =&gt; 1
                  "aircraft_cat" =&gt; 1
                  ]
              #original: array:16 [▶]
              #relations: []
              #hidden: []
              #visible: []
              #appends: []
              #guarded: array:1 [▶]
              #dates: []
              #casts: []
              #touches: []
              #observables: []
              #with: []
              #morphClass: null
              +exists: true
          }
      ]
  }
  </code></pre>