I am using https://github.com/gilbitron/laravel-vue-pagination pagination it works fine.I have included pagination in the page as below
<pagination :data="posts" @pagination-change-page="getResults"></pagination>
and the method
getResults(page = 1) {
axios.get('api/post?page=' + page)
.then(response => {
this.posts = response.data;
});
},
Now when i searchBy Category the pagination links shows api/findByCategoy?category=5&page=1
selectCatgory(e) {
axios.get('api/findByCategoy?category=' + e.target.value)
.then((data) => {
this.posts = data.data
})
.catch(() => {
})
},
I have inclded the GET params in the url . How to change the path in the getResults
public function searchByCategory(){
if ($search = \Request::get('category')) {
$posts = Post::where('category_id',$search)->orderBy('created_at','desc')->paginate(20);
$querystringArray = Input::only(['category']);
$posts->appends($querystringArray);
}else{
$posts = Post::latest()->paginate(10);
}
return $posts;
}