2017-10-16 28 views
0

看到這個蘋果圖標,這些都是從foreach循環中查看,控制器中定義的變量。我可以更改每個圖標,但無法將鏈接分配給每個圖標。Laravel使用控制器鏈接

see this apple icons, these are rendering from foreach loop using controller variable. i can change each icons but not able to assign link to each icon.你好傢伙我卡在鏈接使用laravel控制器。我的代碼是這樣的:(我有一個服務頁面有子服務頁面,只有一個視圖是使用控制器變量來顯示數據,我希望每個頁面按鈕有不同的鏈接,鏈接可以是靜態的我可以從控制器推杆它不要有任何數據庫連接到該溶液中,我想每個HREF作爲單獨的鏈路)

這是景觀:

<?php $index=-1; ?> 
@foreach ($third_fold_3_technologies_list as $item) 
    <?php $index++; ?> 
    <a href="#"><span class="{{ $item }}"></span></a> 
@endforeach 

這是控制器:

$third_fold_3_technologies_list = [ 
    'icon-appleinc', 
    'icon-appleinc', 
    'icon-appleinc', 
]; 
+0

***我希望每個HREF作爲一個單獨的鏈接***表明美國的例子,請 –

+0

示例代碼是以上。你的意思是通過示例瀏覽器截圖? – syedz

+0

意味着你期望作爲輸出 –

回答

1

您可以使用關聯數組。

$third_fold_3_technologies_list = [ 
    'http://<link1>' => 'icon-appleinc', 
    '/<link2>'  => 'icon-appleinc', 
    '<link3>'  => 'icon-appleinc', 
]; 

然後在您的視圖

@foreach ($third_fold_3_technologies_list as $link => $class) 
    <a href="{{ $link }}"><span class="{{ $class }}"></span></a> 
@endforeach