title: How to show checkboxes as checked when values are set in the database in Laravel
body: <p>I'm setting up entrust and trying to manage roles via an edit users page. I have pulled the list of available roles as well as the roles that the user is already assigned to and have them passed to the view as <code>$roles</code> and <code>$assignedRoles</code>.</p>
  
  <p>The problem I'm having is getting the form to show the already assigned roles (<code>$assignedRoles</code>) as checked and the un-assigned roles (remainder of <code>$roles</code>) as not checked.</p>
  
  <p>$roles looks like </p>
  
  <pre><code>    [{"id":1,"name":"Admin","created_at":"2014-09-15 14:26:24","updated_at":"2014-09-15 14:26:24"},{"id":2,"name":"Pastor","created_at":"2014-09-15 14:26:34","updated_at":"2014-09-15 14:26:34"},{"id":3,"name":"Elder","created_at":"2014-09-15 14:26:43","updated_at":"2014-09-15 14:26:43"},{"id":4,"name":"Ministry Leader","created_at":"2014-09-15 14:26:55","updated_at":"2014-09-15 14:26:55"}]
  </code></pre>
  
  <p>and $userRoles looks like</p>
  
  <pre><code>    [{"id":1,"name":"Admin","created_at":"2014-09-15 14:26:24","updated_at":"2014-09-15 14:26:24","pivot":{"user_id":1,"role_id":1}}]
  </code></pre>
  
  <p>I am iterating through the available roles in the view using</p>
  
  <pre><code>@foreach ($roles as $role)
      {{ Form::checkbox('role[]', $role-&gt;id) }}
      {{ Form::label('role', $role-&gt;name) }}&lt;br&gt;
  @endforeach
  </code></pre>
  
  <p>My problem is that I do not know how I can make it so that when viewing the form it will show which roles are already set as per $userRoles (above).</p>