Front end uses pagination and filtering
Created 7 years ago by spotonyI use belongsToMany pagination and filtering!
$relatives = $this->getRelatives();
return $this->belongsToMany(
ApartmentModel::class,
'stores_apartment_categories',
'related_id',
'entry_id'
)->wherePivotIn('related_id', $relatives->ids());
Seek advice
ryanthompson
—
7 years ago
Ah I see:
You can filter like this:
$this->getRelatives()->where('foo', 'bar');
And end with a pagination object like this:
$pagination = $this->getRelatives()->where('foo', 'bar')->paginate();
That will return a Laravel paginator.
spotony
—
7 years ago
Thank you for your help! But unfortunately, it may be my description of the problem did not notice the details!
$relatives = $this->getRelatives();
return $this->belongsToMany(
ApartmentModel::class, // This model uses the ability to filter and search
'stores_apartment_categories',
'related_id',
'entry_id'
)->wherePivotIn('related_id', $relatives->ids());
Such as articles, classified into categories and articles. When I choose a particular category, the number of articles in this category is particularly large! I would expect to give users a search and then detail the screening. Not category need to filter and search Oh! Thank you for giving more help!
$this->getRelatives()->where('foo', 'bar'); // Where the screening is to operate on the category Oh!
Sorry I am not sure what you are asking? I don't see any pagination in there. Is that what you need help with?