title: Loop through two object in laravel
body: <p>I have two arrays of objects and I want to check if ids of elements of both are the same then select option in select box otherwise just display it. I tried like this:</p>
  
  <pre><code> &lt;select multiple class="form-control" name="category_id[]"&gt;
           @foreach($mysliwski as $mysl)
              @if(!$product-&gt;categories-&gt;isEmpty())
                 @foreach($product-&gt;categories as $cat)
                    @if($mysl-&gt;id == $cat-&gt;id)
                        &lt;option selected value="{{$mysl-&gt;id}}"&gt;{{$mysl-&gt;name}}&lt;/option&gt;
                    @else
                        &lt;option value="{{$mysl-&gt;id}}"&gt;{{$mysl-&gt;name}}&lt;/option&gt;
                    @endif
                 @endforeach
            @else
               &lt;option value="{{$mysl-&gt;id}}"&gt;{{$mysl-&gt;name}}&lt;/option&gt;
            @endif
            @endforeach
   &lt;/select&gt; 
  </code></pre>
  
  <p>But it works only when one category is the same. When there are more my select option are duplicated.
  Here are my two 
  <a href="http://laravel.io/bin/ro5rM" rel="nofollow">arrays</a>. Where I have bug?</p>