I asked you for a tip that I have to do something like a question and answer to learn, and I paginated the questions, and the problem is that when I enter the next page, the table of top users is empty, that is, the user table data goes to the next page. It is related to the Thread model and cannot be transferred. This controller code corresponds to this section
public function index()
{
$users=User::query()->orderByDesc('score')->paginate(10);
$threads = Thread::whereFlag(1)->with(['channels:id,name,slug','user:id,name'])->latest()->paginate(3);
return view('answer-question.thread.thread', compact('threads','users'));
}
And this is the code related to View
<div class=" container-fluid row mr-1 ">
@foreach($threads as $thread)
<div class=" col-lg-8 col-md-6 col-sm-12">
<div class="card my-3 rounded-lg mr- ">
<div class="card-body shadow ">
<blockquote class="blockquote mb-0">
<div class=" d-flex">
<p style="font-size: x-large; font-weight: bold; "><a class="" href="/threads/{{$thread->slug}}">{{$thread->title}}</a></p>
<p class=" text-success" style="margin-right: auto; font-size: 16px;">6پاسخ</p>
</div>
<div class=" d-flex">
<img class="img-profile rounded-circle mr-1 " style="width: 60px; height: 60px;"
src="{{asset('./answer-question/thread/circled-user-male-skin-type-1-2.png')}}">
<p class="mt-3 text-secondary" style="font-size: 15px;">{{jdate($thread->created_at)->format('%A, %d %B %y')}}
توسط {{$thread->user->name}} آپدیت شد
</p>
</div>
<footer class="blockquote-footer text-dark">{{\Illuminate\Support\Str::limit($thread->description,140)}}<cite title="Source Title"></cite></footer>
@can('user-thread',$thread)
<form action="{{ route('threads.destroy' , ['thread' => $thread->id]) }}" method="POST">
@csrf
@method('DELETE')
<div class=" d-flex">
<div class=" btn btn-danger mr-auto">حذف</div>
</div>
</form>
@endcan
</blockquote>
</div>
</div>
</div>
@endforeach
<div class="col-lg-4 col-md-6 col-sm-12 d-sm-blok">
<div class="card bg-dark shadow rounded-lg mt-3 text-light ">
<div class="card-header ">
کاربران برتر این هفته
</div>
<div class="card-body ">
<blockquote class="blockquote mb-0">
@foreach($users->where('score','>',0) as $user)
<div class=" d-flex">
<img class="img-profile rounded-circle mr-1 " style="width: 60px; height: 60px;border: 3px solid green"
src="{{asset('./answer-question/thread/circled-user-male-skin-type-1-2.png')}}">
<p class="mt-3 mr-3 mb-3" style="font-size: 15px;font-size: large">
{{$user->name}}</p>
<span class="mr-auto mt-1">{{$user->score}}</span>
</div>
@endforeach
</blockquote>
</div>
</div>
<div class="card-footer">
{{$threads->appends(['search'=>request('search')])->render()}}
</div>
</div>
I think I should use appends or render, but I do not know that at the end of the view I used this code to paginate the questions, I do not know how to send top users to it that is on all pages.
<div class="card-footer">
{{$threads->appends(['search'=>request('search')])->render()}}
</div>
Thank you for your help