Kareimovich's avatar

Anime Episode pagination

I want to reverse the Episode order of each Anime post. Also apply pagination to it. Please Help.

public function index()
{
    $animes =  Anime::paginate(2);


    return view('welcome',compact('animes'));
}

public function view(anime $anime) { return view('show', compact('anime'));

}

@extends ('layouts.animes')

@section ('content')

  <section class="jumbotron text-center">
    <div class="container">
      <h1 class="jumbotron-heading">{{ $anime->anime_name}}</h1>
      <img class="img-top"  src="{{ Storage::url($anime->anime_img) }}" alt="Anime_image">

      <p class="lead ">{{$anime->anime_story}}</p>
      <p>
        <a href="/avatars/create" class="btn btn-primary my-2">Make New One</a>
      </p>
    </div>
  </section>

@foreach ($anime->episode as $episode)

{{ $episode->episode_Name}}

{{$episode->anime_story}} Watch Downolad
@endforeach

 </main>

@endsection

0 likes
1 reply
lostdreamer_nl's avatar
Level 53
@foreach ($anime->episode->reverse() as $episode)

That should reverse your collection of episodes within this anime show.

Please or to participate in this conversation.