2

I would like to use a value inside a for loop in foreach in blade file. Does anyone know how to do this? I would like to do something like this:

@for ($i = 0; $i < 10; $i++)
    @foreach($meals->where('meal_category_id', {{ for loop value }}) as $meal))

    @endforeach
@endfor

Thanks for help :)

1 Answer 1

4

Did you try:

@for ($i = 0; $i < 10; $i++)
    @foreach($meals->where('meal_category_id', '=', $i) as $meal))
        {{ $meal }}
    @endforeach
@endfor
Sign up to request clarification or add additional context in comments.

2 Comments

Holy moly, why the simplest solutions are the most difficult? Thank you so much, works perfect!
Hey @JaroslawNowak ! If the answer solved your issue, you should kindly mark the answer as accepted so that future answer seekers are directed properly :)

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.