Foreach

Posted 6 months ago by hjortur17

Hi, I need ​quick help regarding my foreach loop. I want to run though all the places that is in the state Vestfirdir. But I can't figure out have I can only get these place insted of every places. Do I need to do this in the Controller?

@if ($places->contains('state', 'vestfirdir'))
    @foreach ($places as $place)
        <div class="w-auto lg:w-64 xl:w-64 p-2 text-center lg:text-left xl:text-left">
            <a href="{{ $place->path() }}" class="font-light link text-blue-light">{{ $place->title }}</a>
        /div>
    @endforeach
@else
    <div class="w-auto lg:w-64 xl:w-64 p-2 text-center">
        <p class="font-light link text-grey-darker">@lang('camping.announcment')</p>
    </div>
@endif

Please sign in or create an account to participate in this conversation.