I'm try to make redirect page with slug if have activity to page activity and if news redirect to news page. but when i make if else in foreach cannot.
this my controller
$term = request('search');
$results = Search::add(activity::class, 'title','activity', 'district')
->add(news::class, 'title','body')
->beginWithWildcard()
->get($term);
return view('/search',[
**'search' => $results,**
'term' => $term,
]);
}
this is may view :
<div class="ride_section_2 layout_padding mt-5">
@foreach ($search as $item)
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="image_3"><img src="https://source.unsplash.com/700x300?nature,water" class="card-img-top mb-3" alt=""></div>
</div>
<div class="col-sm-8">
<h1 class="cabe_text"></h1>
<p class="long_text"> <br>
**@if ($item->count() > 0 )
<a href="/posts/">read more...</a> </p>
@else
<a href="/news/">read more...</a> </p>
@endif**
</div>
</div>
</div>
@endforeach
</div>
Aucun commentaire:
Enregistrer un commentaire