Laravel 5.4 foreach循环不会重复多次

时间:2017-08-09 23:50:56

标签: laravel laravel-5 foreach blade laravel-blade

我正在构建一个登陆页面,我有两个foreach循环,第一个循环只重复一次,即使它应该重复6次,如果我删除第二个循环它正常工作,第二个循环应该只重复一次,并使用find(1 );进行探测而不使用第二个循环,但完全相同的事情发生了,任何想法?

我的代码:

@foreach($gaInfo as $gi)
    {{$gi->title}}
<!--Home end-->
<section id="nosotros">
    <div class="padding-one">
        <div class="containr">
            <div class="row">
                <div class="col-sm-12 wow fadeInLeft">
                    @if($gi->section == 'abouts' && $gi->lang == $lang)
                    <h2>{{ $gi->title }}</h2>
                    @endif
                    <hr>
                    <div class="row">
                        <div class="col-sm-8 wow col-xs-12">
                            <div class="text-center p-margin">
                                @foreach($abouts as $about)
                                    {{$about->description}}
                                @endforeach
                            </div>
                        </div>
@endforeach

$ gaInfo包含6个条目,$ abouts只包含一个条目,抱歉我的英文不好。

控制器:

$sliders = new slider();
        $abouts = new about();
        $contact = new contact();
        $projects = new project();
        $customers = new customer();
        $services = new service();
        $gacimsInfo = new gacimsInfo();
        $goals = new Goal();
        $views = new View();
        $missions = new Mission();
        $teams = new team();
        $request->lang = 'es';

        $data = [
            'sliders' => $sliders->get(),
            'abouts' => $abouts->get(),
            'contact' => $contact->get(),
            'projects' => $projects->get(),
            'customers' => $customers->get(),
            'services' => $services->get(),
            'gacimsInfo' => $gacimsInfo->get(),
            'lang' => $request->lang,
            'goals' => $goals->get(),
            'views' => $views->get(),
            'missions' => $missions->get(),
            'teams' => $teams->get(),
            ];

        return view('home', $data);

0 个答案:

没有答案