我能够按地理位置和国家/地区创建群组,效果很好(参见图片附件)
控制器
$table_companies = Clients::selectRaw('geography geography, country country')->groupBy('geography', 'country')->get()->toArray();
return view('about.our-clients', compact('our-clients','table_companies'));
查看
@foreach ($table_companies as $geography)
<div class="row">
<div class="col-lg-12 text-center"
style="color:#000000">
<h2 class="bigFont text-center">
{{ $geography['geography'] }}
</h2>
</div>
@foreach ($table_companies as $country)
<div class="col-lg-12" style="padding:25px 0">
<h2 class="text-center"
style="background-color:#000000;
color:#ffffff;
font-size:1.4em;padding:5px 0;">
{{ $country['country'] }}
</h2>
</div>
<div class="col-lg-12">
<div class="row">
<!--Company names will be loaded here-->
</div>
</div>
@endforeach
</div>
<br><br>
@endforeach
当我尝试获取公司名称时,问题就开始了
控制器
$table_companies = Clients::selectRaw('geography geography, country country, name_company company')->groupBy('geography', 'country', 'company')->get()->toArray();
查看
@foreach ($table_companies as $geography)
<div class="row">
<div class="col-lg-12" class="text-center" style="color:#000000">
<h2 class="bigFont text-center">
{{ $geography['geography'] }}
</h2>
</div>
@foreach ($table_companies as $country)
<div class="col-lg-12" style="padding:25px 0">
<h2 class="text-center"
style="background-color:#000000;
color:#ffffff;
font-size: 1.4em;
padding:5px 0;">
{{ $country['country'] }}
</h2>
</div>
<div class="col-lg-12">
<div class="row">
@foreach ($table_companies as $companies)
<div class="col-sm-4">{{ $companies['company'] }}</div>
@endforeach
</div>
</div>
@endforeach
</div>
@endforeach
此页面无效 127.0.0.1目前无法处理此请求。 HTTP ERROR 500
答案 0 :(得分:0)
我使用普通的vanilla来渲染页面并按照我想要的方式分组。谢谢。