title: Laravel set checkboxes checked based on database value
body: <p>I am trying to set checkboxes checked based on database value. One user can have have multiple checkbox values. </p>
  
  <p>Checkboxes are generated from database table called <code>child_age_groups</code>:</p>
  
  <pre><code>   @foreach ($child_age_groups as $age)
        &lt;div class="checkbox checkbox-info checkbox-inline"&gt;
           &lt;input class="age_group_checkbox" type="checkbox" name="age_group[]" id="age_group{{$age-&gt;id}}" "/&gt;
          &lt;label for="age_group{{$age-&gt;id}}"&gt;{{$age-&gt;age_group}}&lt;/label&gt;
       &lt;/div&gt;
    @endforeach
  </code></pre>
  
  <p>So in my controller I get all the options that user has like this</p>
  
  <pre><code>  $nanny_babysitting_ages      = Nanny_babysitting_ages::where('user_id', user()-&gt;id)-&gt;get();
  </code></pre>
  
  <p>My nanny_babysitting_ages table is this</p>
  
  <pre><code>user_id | ages
  </code></pre>
  
  <p>and my child_age_groups table where I populate the checkboxes are this:</p>
  
  <pre><code>id | age_group
  </code></pre>
  
  <p>How can I set the checkboxes selcted based on the values from database?</p>