Tanvir Alam Tanvir Alam - 5 months ago 22
SQL Question

php Issue with Intro.js using it in a foreach loop

I have decided to use Intro.js to create a guide for my website.

But I have this issue. If I put Intro.js in a loop it works for all the rows it generate. so each loop generate 50 rows dynamically from result from DB and hence generate 50 intro.js.

Is there way to

break;
or
stop
Intro.js not go through the entire loop and focus on one row instead?

@foreach($providers as $key => $provider)
<tr data-intro="{{ TL::helpdesk('viewvilkareachrowdescription') . $provider->name }}"></tr>
@endforeach


Hope its possible? please help anyone?

Answer

you can use an if statement to do something on only one row and print the others.

here is an example :

  @foreach($providers as $key => $provider)

        @if ($provider->name == 'any_name')
             ... // << case focus on one row 
        @else
             <tr data-intro="{{ TL::helpdesk('viewvilkareachrowdescription') . $provider->name }}"></tr>
        @endif

    @endforeach

and here is a link to documentation about Blade Templating : https://laravel.com/docs/5.0/templates