title: Laravel eloquent One to Many relation
body: <p>I cannot figure out how to define one to many relation using <code>Eloquent</code>.</p>
  
  <p>Here are tables </p>
  
  <pre><code>----------- Country -----------
  id | title | code | currency_code
  
  ----------- Currency Code --------
  id | name | symbol | code 
  </code></pre>
  
  <p>One country may have many currencies. </p>
  
  <p>Therefore I defined my models as follows </p>
  
  <pre><code>class Country extends Model
  {
      public function currencies()
      {
          $this-&gt;hasMany('App\Models\Currency', 'code', 'currency_code');
      }
  
  }
  </code></pre>
  
  <p>And the Currency model is simple </p>
  
  <pre><code>class Currency extends Model
  {
  
  
  }
  </code></pre>
  
  <p>And I am selecting countries like that </p>
  
  <pre><code>   return Country::all('country_id AS value', 'title_ru AS title','currency_code')
     -&gt;sortBy('value');
  </code></pre>
  
  <p>But it returns null when I try to access currencies </p>
  
  <p>What is wrong with my definitions, I would be grateful for any help. </p>
  
  <p>Thanks</p>