Laravel по-русски

Русское сообщество разработки на PHP-фреймворке Laravel.

Ты не вошёл. Вход тут.

#1 12.06.2015 14:22:42

Arat
Откуда: Киев
Сообщений: 116

Получение моделей и разбивка на части. Вопрос о верстке Bootstrap

Есть задача вывести, условно, поплуярные товары в карусель вида:

PHP
<div class="carousel slide" id="myCarousel">
        <
div class="carousel-inner">
            <
div class="item active">
                    <
ul class="thumbnails">
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                    </
ul>
              </
div><!-- /Slide1 -->
            <
div class="item">
                    <
ul class="thumbnails">
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                    </
ul>
              </
div><!-- /Slide2 -->
            <
div class="item">
                    <
ul class="thumbnails">
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                        <
li class="col-sm-3">
                            <
div class="fff">
                                <
div class="thumbnail">
                                    <
a href="#"><img src="http://placehold()it/360x240" alt=""></a>
                                </
div>
                                <
div class="caption">
                                    <
h4>Praesent commodo</h4>
                                    <
p>Nullam Condimentum Nibh Etiam Sem</p>
                                    <
class="btn btn-mini" href="#">» Read More</a>
                                </
div>
                            </
div>
                        </
li>
                    </
ul>
              </
div><!-- /Slide3 -->
        </
div>


       <
nav>
            <
ul class="control-box pager">
                <
li><a data-slide="prev" href="#myCarousel" class=""><class="glyphicon glyphicon-chevron-left"></i></a></li>
                <
li><a data-slide="next" href="#myCarousel" class=""><class="glyphicon glyphicon-chevron-right"></i></li>
            </
ul>
        </
nav>
       <!-- /.
control-box -->

    </
div><!-- /#myCarousel -->

Т.е. разбивка на блоки по 4 модели из коллекции, каждый из которых, при показе принимает параметр «active».
Как разбить на части всю коллекцию в таком случае?

Не в сети

#2 16.06.2015 09:52:31

Arat
Откуда: Киев
Сообщений: 116

Re: Получение моделей и разбивка на части. Вопрос о верстке Bootstrap

Model::chunk() не подойдет для такой задачи?

Не в сети

#3 02.07.2015 16:21:11

Arat
Откуда: Киев
Сообщений: 116

Re: Получение моделей и разбивка на части. Вопрос о верстке Bootstrap

Совсем нет идей?

Не в сети

Подвал раздела