title: Laravel - How use HasMany
body: <p>I have a little problem with model relationships.</p>
  <p>I have a Users table and a Appartaments table, with a hasmany relationship linked from the ref_user field(Users) to the agent field(Appartaments). Neither is a primary key.</p>
  <p>In my User model I have:</p>
  <pre><code>    public function appartaments(){
      return $this-&gt;hasMany(Appartament::class,'agent','ref_user');
  }
  public function idAppartaments($id){
      return User::find($id)-&gt;appartaments;
  }
  </code></pre>
  <p>In my controller I have:</p>
  <pre><code>public function getAppUser($ref_user){
      $id = User::select('id')-&gt;where('ref_user',$ref_user)-&gt;get();
      $appartaments = User::idAppartaments($id);
      return $appartaments;
  </code></pre>
  <p>When I try the route however, I get an error that the appartaments property does not exist.</p>