bladeに多次元配列を渡してループさせる
bladeのforeachに多次元配列を指定する方法を書きます。まずblade側。
<ul class="breadcrumb"> @foreach($breadcrumbs as $breadcrumb) <li><a href="{{ URL::to('./' . $breadcrumb['href']) }}">{{ $breadcrumb['name'] }}</a></li> @endforeach </ul>
コントローラー側。
public function index() { return View::make('hello.index')->with('breadcrumbs', [ ['href' => 'url1', 'name' => 'リンク1'], ['href' => 'url2', 'name' => 'リンク2'], ['href' => 'url3', 'name' => 'リンク3'], ]); }