title: Override primary key with foreign key in hasMany relation using laravel
body: <p>Here are my tables</p>
  
  <pre><code>Posts
  
  id | name | created_At
  
  Comments
  
  id | comment | post_id | created_at
  </code></pre>
  
  <p>Post Model</p>
  
  <pre><code>function comments(){
        return $this-&gt;hasMany('App\Models\Comment','id','post_id');
   }
  </code></pre>
  
  <p>PostsController</p>
  
  <pre><code>function index()
  {
      Post::with('comments')::get();
  }
  </code></pre>
  
  <p>Now how can i get list of all posts along with comments?</p>
  
  <p>I am trying to match post_id in the child table.</p>