You need use the search query above the articles variable. Like this way.
Because everytime it will paginate for page wise. If you paginate for the second page it may not contain any data. That's why you are getting the 0 value for the other page. Please use this way, i think problem will be solved.
// Search results count
if ($request->input('search')) {
$article_count = $articlesQuery->count();
}
$articles = $articlesQuery->orderBy('id', 'desc')->paginate($this->per_page);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community