title: Display the value from laravel relationship?
body: <p>I am using laravel 5.1 with mongodb, I need to display users list on a blade, i am using Laravel relationship method(hasMany), i tried but i got</p>
  
  <pre><code>error(Undefined property: Illuminate\Database\Eloquent\Collection::$roles)
  </code></pre>
  
  <p>Table structure:</p>
  
  <pre><code>users-&gt; userid, username,email, roleid.
  user_roles-&gt;roleid,rolename;
  </code></pre>
  
  <p>my question is simple, i want userdetails from user table with rolename, i have attached my query result image.any suggesstion please?
  Controller:</p>
  
  <pre><code>$users =User::with('roles')-&gt;get();
  return view('Manage_users', compact('users'));
  </code></pre>
  
  <p>User Model:</p>
  
  <pre><code>class User extends Eloquent 
  {
    protected $collection = 'users';
  
    public function roles()
      {
          return $this-&gt;hasMany('App\User_role','roleid','roleid');
      }
  
  }
  </code></pre>
  
  <p>User_roles Model:</p>
  
  <pre><code>class User_role extends Eloquent
  {
    protected $collection = 'user_roles';
  
  
    public function user()
      {
          return $this-&gt;belongsTo('App\User','roleid','rolename');
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TDqa0.png" rel="nofollow noreferrer">My query result image</a></p>
  
  <p><a href="https://i.stack.imgur.com/qczkd.png" rel="nofollow noreferrer">My view page result
  </a></p>