Level 102
You need to set the page name. It is the third argument
$listingsActive = Listing::where('user_id', Auth::user()->id)
->where('display', 'active')
->orWhere('display', 'hidden')->paginate(4, ['*'], 'active');
1 like
Hi, sorry if the title is confusing . Basically I've 3 paginators on one page. There's 3 boxes with a list of items.
It doesn't matter which one i click, the content off all the 3 boxes changes when i click on the paginator. What i want is that every paginator only controls one part.
How can I do this? (The reason I use livewire is because I'm going to put a searchbar in it.)
class ListingListPrivate extends Component
{
use WithPagination;
protected $paginationTheme = 'bootstrap';
use AuthorizesRequests;
public function render()
{
$listingsActive = Listing::where('user_id', Auth::user()->id)
->where('display', 'active')
->orWhere('display', 'hidden')->paginate(4);
$listingsInactive = Listing::where('user_id', Auth::user()->id)
->where('display', 'inactive')->paginate(4);
$listingsTrashed = Listing::where('user_id', Auth::user()->id)
->where('display', 'deleting')->paginate(4);
return view(
'livewire.listing-list-private',
[
'listingsActive' => $listingsActive,
'listingsInactive' => $listingsInactive,
'listingsTrashed' => $listingsTrashed,
]
);
}
}
View:
<div>
<div class="descriptionbox mb-3">
<h2 class="h5">Active listings</h2>
@foreach ($listingsActive as $listing)
<x-listing :listing="$listing" />
@endforeach
{{$listingsActive->links()}}
</div>
<div class="descriptionbox mb-3">
<h2 class="h5">Inactive listings</h2>
@foreach ($listingsInactive as $listing)
<x-listing :listing="$listing" />
@endforeach
{{$listingsInactive->links()}}
</div>
<div class="descriptionbox mb-3">
<h2 class="h5">Deleted listings</h2>
@foreach ($listingsTrashed as $listing)
<x-listing :listing="$listing" />
@endforeach
{{$listingsTrashed->links()}}
</div>
</div>
You need to set the page name. It is the third argument
$listingsActive = Listing::where('user_id', Auth::user()->id)
->where('display', 'active')
->orWhere('display', 'hidden')->paginate(4, ['*'], 'active');
Please or to participate in this conversation.