title: get the id from hasManyThrough relationship in laravel
body: <p>I have 3 tables</p>
  
  <p>Users table</p>
  
  <p><a href="https://i.stack.imgur.com/A5bnd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A5bnd.png" alt="enter image description here"></a></p>
  
  <p>Loan Amounts Table</p>
  
  <p><a href="https://i.stack.imgur.com/hmkWO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hmkWO.png" alt="enter image description here"></a></p>
  
  <p>Grant Loan amounts table</p>
  
  <p><a href="https://i.stack.imgur.com/XvddL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XvddL.png" alt="enter image description here"></a></p>
  
  <p>on my user model i used hasManyThrough relationship</p>
  
  <pre><code>public function loan_amounts()
  {
      return $this-&gt;hasManyThrough(
          'App\LoanAmount',
          'App\GrantLoanAmount',
          'user_id',
          'id',
          'id',
          'amount_id'
      );
  }
  </code></pre>
  
  <p>this relationship display the loan_amounts->amount in my user.show blade.</p>
  
  <p>so if i just do {{$user}} it display the following:</p>
  
  <pre><code>{
      "id":13,
      "name":"antonitte",
      "email":"antonitte!23@yahoo.com",
      "email_verified_at":null,
      "phone_number":"09472315875",
      "verification_code":null,
      "phone_verified_at":null,
      "avatar":"user.jpg",
      "created_at":"2019-09-23 18:50:57",
      "updated_at":"2019-09-23 18:50:57",
      "loan_amounts":[
          {"id":1,"amount":"5000.00","default":1,"created_at":"2019-09-23 02:45:30","updated_at":"2019-09-23 02:45:30","laravel_through_key":13},
          {"id":4,"amount":"20000.00","default":0,"created_at":"2019-09-23 02:46:37","updated_at":"2019-09-23 02:46:37","laravel_through_key":13},
          {"id":2,"amount":"10000.00","default":0,"created_at":"2019-09-23 02:46:08","updated_at":"2019-09-23 02:46:08","laravel_through_key":13}
      ]
  }
  </code></pre>
  
  <p>which is good. But my problem is I want to grab the id of grant_loan_amounts->id. so that I can send it to GrantLoanAmountsController@destroy for deletion </p>
  
  <p><a href="https://i.stack.imgur.com/bvomb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bvomb.png" alt="enter image description here"></a></p>
  
  <p>any suggestions? thanks!</p>