title: Laravel best way to pre-select checkbox fields from database
body: <p>I am building an app that has users and roles.  I want users with the Administrator role to be able to change other user roles.  For example add/remove them from other roles.</p>
  
  <p>To do this, I have setup a form with checkboxes, which lists out all of the user roles available:</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;fieldset&gt;
      &lt;legend&gt;Groups&lt;/legend&gt;
      @foreach($roles as $role)
          {!! Form::checkbox($role-&gt;field) !!} &lt;span&gt;{{ $role-&gt;name }}&lt;/span&gt;&lt;br&gt;
      @endforeach
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>This results in the following being produced:</p>
  
  <pre><code>[] Administrator
  [] Supervisor
  [] Employer
  [] Contractor
  </code></pre>
  
  <p>I have a method which I use to load roles that the user belongs to:</p>
  
  <pre><code>/**
   * Get all user roles.
   *
   * @param $id
   * @return Collection
   */
  public function getUsersRoles($id)
  {
      return $this-&gt;roleUser-&gt;where('user_id', $id)-&gt;get();
  }
  </code></pre>
  
  <p>The above method returns an object containing each role.</p>
  
  <p><strong>How can I use this method to pre-select roles which the user belongs to on my view?</strong></p>