0

see this apple icons, these are rendering from foreach loop in view, defined variable in controller . i can change each icons but not able to assign link to each icon.

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.Hello guys i am stuck in linking using laravel controller.

my code is something like that: (i have a service page which has sub services page there is only one view which is using controller variable to showing data. i want each page button have different links. links can be static so i can putt it from controller. dont have any database attached to this solution. i want each href as a separate link)

This is view:

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

This is controller:

$third_fold_3_technologies_list = [
    'icon-appleinc',
    'icon-appleinc',
    'icon-appleinc',
];
7
  • i want each href as a separate link show us example please Commented Oct 16, 2017 at 14:58
  • the example code is above. what you mean by example browser screenshot? Commented Oct 16, 2017 at 14:59
  • meant what you expecting as output Commented Oct 16, 2017 at 15:00
  • oh ok i want to redirect to another page. like i want to put custom link by my self using controller variable. Commented Oct 16, 2017 at 15:01
  • I'm not understanding the problem. Commented Oct 16, 2017 at 15:17

1 Answer 1

1

You can use associative array.

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

Then in your view

@foreach ($third_fold_3_technologies_list as $link => $class)
    <a href="{{ $link }}"><span class="{{ $class }}"></span></a>
@endforeach 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.