php - The same posts shows to times -


layout

the problem here red marked news same. , want here make sure new posts wont repeat themselves. because can see same posts shows 2 times before posted.

this code:

    @extends('app')  @section('content')      <div class="row">          <div class="col-xs-12 col-sm-9">            @if(count($latest))           <div class="col-md-12">           <a href="/post/{{$latest->slug}}/{{$latest->id}}">             <img class="img-responsive" src="{!! url($latest->image) !!}" alt="" style="padding: 0px; height: 400px; width: 720px"></a>             <h2 class="post" style="margin-top: 0; color: #666">                @foreach($latest->category $cat)                 <a style="color: red; text-transform: uppercase; font-size: 13px" href="/categories/{{$cat->name}}">{{$cat->name}}</a>               @endforeach              <br><a href="/post/{{$latest->slug}}/{{$latest->id}}">{!! strip_tags(link_to_action('postscontroller@show', $latest->title, [$latest->slug, $latest->id])) !!}</a></h2>             <span style="color: #b8b8b8">paskeblta {{$latest->created_at}}</span>             <hr>           </div>           @else            <p>nėra naujienų</p>           @endif            <div class="row">             @foreach($posts $post)             <div class="col-xs-6 col-lg-6">             <a href="/post/{{$post->slug}}/{{$post->id}}">             <img class="img-responsive" style="width: 352px; height: 180px" src="{!! url($post->image) !!}" alt=""></a>               <h3 class="post" style="font-size: 1.4em; margin-top: 0; color: #666"><small style="color: red; text-transform: uppercase; font-size: 11px">                @foreach($post->category $cat)                 {{$cat->name}}               @endforeach                </small><br><a href="/post/{{$post->slug}}/{{$post->id}}">{{strip_tags($post->title)}}</a></h3>               <span style="color: #b8b8b8">paskelbta {{$post->created_at}}</span>               <br><br>             </div><!--/.col-xs-6.col-lg-4-->              @endforeach           </div><!--/row-->         </div><!--/.col-xs-12.col-sm-9-->          @include('comp.sidebar')       </div><!--/row-->        <hr> @stop 

you add check in loop: if current post same featured one, ignore it.

@foreach($posts $post)     @unless ($post == $latest)         // rest of html goes here     @endunless @endforeach 

if objects aren't same objects, change check accordingly - e.g. @unless ($post->id == $latest->id) or similar.


Comments