title: laravel loop add active class to first item of loop
body: <p>I'm trying to display dynamic data in bootstrap tabs. For that I want to add active class to the first item. How can I do that??
  My blade code</p>
  <pre><code> &lt;div id=&quot;rootwizard&quot;&gt;
                                      &lt;ul class=&quot;nav nav-tabs wizard&quot; role=&quot;tablist&quot;&gt;
                                      @foreach( $places as $place)
                                              &lt;li class=&quot; active&quot; style=&quot;&quot;&gt;&lt;a href=&quot;#{{$place-&gt;id}}&quot; role=&quot;tab&quot; data-toggle=&quot;tab&quot;&gt;{{$place-&gt;name}}&lt;/a&gt;&lt;/li&gt;
                                      @endforeach
                                           
                                      &lt;/ul&gt;
  
  
                                      &lt;div class=&quot;tab-content&quot;&gt;
                                              @foreach($places as $place)
                                              &lt;div class=&quot;tab-pane fade active in&quot; id=&quot;{{$place-&gt;id}}&quot;&gt;
                                                      &lt;div class=&quot;row&quot;&gt;
                                                          &lt;div class=&quot;col col-md-4&quot;&gt;
                                                              &lt;img class=&quot;img-responsive&quot; src=&quot; 
                                   {{'/storage/places/'.$place-&gt;image}}&quot; alt=&quot;&quot;&gt;
                                                          &lt;/div&gt;
                                                          &lt;div class=&quot;col col-md-4&quot;&gt;
                                                    
                                                                  {{$place-&gt;intro}}
                                                            
                                                &lt;a href=&quot;#&quot; class=&quot;btn btn-info&quot;&gt;Read More&lt;/a&gt;
                                                          &lt;/div&gt;
                                                          &lt;div class=&quot;col col-md-4&quot;&gt;
           &lt;img class=&quot;img-responsive&quot; src=&quot;{{'front/images/maps/map-sample.PNG'}}&quot; alt=&quot;map&quot;&gt;
                                                          &lt;/div&gt;                  
                                                      &lt;/div&gt;
                                              &lt;/div&gt;
                                              @endforeach
  </code></pre>
  <p>And my controller</p>
  <pre><code> $place = Place::orderby('id', 'asc')-&gt;get();
  </code></pre>