title: Laravel hasMany and belongsTo parameters
body: <p>I have a table store, and store has many libraries, in library I have foreign key of store <code>store_id</code>.</p>
  <p>Store table</p>
  <pre><code>id(PK)
  </code></pre>
  <p>Library table</p>
  <pre><code>id(PK)
  store_id(FK)
  </code></pre>
  <p>I'm confused with <code>hasMany</code> and <code>belongsTo</code> parameters include, in the <a href="https://laravel.com/docs/5.5/eloquent-relationships#one-to-many" rel="noreferrer">docs</a> it says</p>
  <blockquote>
  <p>return $this-&gt;hasMany('App\Comment', 'foreign_key');</p>
  <p>return $this-&gt;hasMany('App\Comment', 'foreign_key', 'local_key');</p>
  <p>return $this-&gt;belongsTo('App\Post', 'foreign_key', 'other_key');</p>
  </blockquote>
  <p>Which table of hasMany foreign_key and local_key came from? Same with belongsTo which table of foreign_key and other_key came from?</p>
  <p>Store model</p>
  <pre><code>public function library(){
      return $this-&gt;hasMany('App\Library', 'what_foreign_key_should_be_here','what_other_key_should_be_here');
  }
  </code></pre>
  <p>Library model</p>
  <pre><code>public function stores(){
      return $this-&gt;belongsTo('App\Stores', 'what_foreign_key_should_be_here', 'what_other_key_should_be_here');
  }
  </code></pre>
  <p>Because sometimes I change my primary key id of a table to other name like sid, so I always want to specify which is foreign key and primary key</p>