title: How to make user, and roles relationship in Laravel 5
body: <p>I have two tables :</p>
  <pre><code>User -&gt;
    id : 
    name : 
    role_id : -&gt;references('id')-&gt;on('roles');
  
  Roles -&gt;
    id :
    role_name :
    access :
  </code></pre>
  <p>I am trying to access roles details from user.</p>
  <p>My User model has:</p>
  <pre class="lang-php prettyprint-override"><code>public function role()
  {
      return $this-&gt;belongsTo('App\Role');
  }
  </code></pre>
  <p>My Role model has:</p>
  <pre class="lang-php prettyprint-override"><code>public function user()
  {
      return $this-&gt;hasMany('App\User');
  }
  </code></pre>
  <p>When I try to do following :</p>
  <pre class="lang-php prettyprint-override"><code>$user = User::find(1);
  
  $details = [
      'name' =&gt; $user-&gt;first_name,
      'role' =&gt; $user-&gt;role-&gt;role_name
  ];
  </code></pre>
  <p>I get error :</p>
  <blockquote>
  <p>Trying to get property of non-object</p>
  </blockquote>
  <p>My roles table contains access columns containing array of permissions to different routes. So my user will have only one role. While a role can have multiple users.</p>
  <p>How to do that?</p>