What I intend is to get the news $new in a certain language if($new_lang->lang_id == $lang_id), then I look in the table of images @foreach($data['images'] as $image) which corresponds to the news and which is the main one @if($image->imageable_id == $new->id && $image->main == '1').
The problem is that when nesting foreachs, the load is very slow, since they are more than 7,000 news and some 70,000 images.
How to get the same result without nesting one foreach inside another?
@foreach($new->langs as $new_lang)
@if($new_lang->lang_id == $lang_id)
@foreach($data['images'] as $image)
@if($image->imageable_id == $new->id && $image->main == '1')
@php
$mini = substr($image->path, 0, strrpos( $image->path, "/"));
$name = substr($image->path, strrpos($image->path, '/') + 1);
$image_mini = $mini.'/mini-'.$name;
@endphp
<div class="crop">
<a href=""></a>
</div>
@endif
@endforeach
@endif
@endforeach
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire