Support the ongoing development of Laravel.io →
Views Blade
Last updated 1 year ago.
0

Can you provide a sample code in which we can tweak?

Last updated 1 year ago.
0

Thanks for the help

       @foreach($place->attested[$counter] as $attestation)

            
         //so attestation at this point should be an array 
         //however it comes out as strings

        @endforeach

It is from the $place Model which when debugged looks like this https://www.dropbox.com/s/uelptxl707thd8t/Screen%20Shot%202014...

Last updated 1 year ago.
0

What is $counter? Isn't it just @foreach($place->attested as $attestation)? Can you var_dump your $place->attested[$counter] or $place->attested objects?

Last updated 1 year ago.
0

@barryvdh thanks for the help

$counter is used cos I am trying to essentially link two ordered items this loop is inside another , I think by questioning that you have made me realise this is getting overly complicated for a view and the work would be much better done at a higher level

@foreach ($place->historicalForm as $historicalForm)

    <li><a href="#histform-<?php echo $counter;?>">{{ $historicalForm}}</a>

        <!-- attestations -->
        @if($counter<count($place->attested))
        @foreach($place->attested[$counter] as $attestation)

            <?php $att =  (array) $attestation;?>
            {{var_dump($att)}}

        @endforeach
        @endif
        <!--end -->

    </li>

    <?php $counter++;?>
@endforeach

this is what I was doing - which results in array(5) { ["histform"]=> string(5) "Ackle" ["sources"]=> string(2) "Ch" ["sourceId"]=> string(4) "bu15" ["dates"]=> string(4) "1228" ["attestation"]=> string(23) "'wood of Ackle' 1228 Ch" } from the var_dump

Last updated 1 year ago.
0

As discussed above -> I have now returned the inner array (attested) as a view variable therefore I can use counter to obtain info from that easily -- thanks to all for help

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.