Dumitru
Dumitru

Reputation: 2183

Laravel LengthAwarePaginator where query

I have LengthAwarePaginator in variable dataTypeContent, when I use where he do query only on first page. But I need on all pages and return new filtered items by where.

$dataTypeContent->where('category_id', 48);

LengthAwarePaginator {#303 ▼
    #total: 283
    #lastPage: 19
    #items: Collection {#1 ▶}
    #perPage: 15
    #currentPage: 1
    #path: "/admin/products"
    #query: []
    #fragment: null
    #pageName: "page"
}

More code: https://github.com/the-control-group/voyager/blob/1.1/src/Http/Controllers/VoyagerBaseController.php

How I can do where on all pages?

Upvotes: 0

Views: 746

Answers (1)

bangnokia
bangnokia

Reputation: 259

I see your variable $dataTypeContent = $someQuery->paginate();

You should use where before paginate(). $dataTypeContent = $someQuery->where()->paginate();

Upvotes: 1

Related Questions