Reputation: 28
I have my URL as api/listing/stores?category=category_name for this store list under category my code using :
$store_list=DB::table('s_local_store_category')
->where('s_local_store_category.cat_id',$business_categories_id)
->join('s_loacalstors','s_local_store_category.store_id','=','s_loacalstors.localstoreid')
->select('s_loacalstors.*')
->orderBy('name','ASC')
->Paginate(1);
my output in json :
"store":{
"total":2,
"per_page":1,
"current_page":1,
"last_page":2,
"next_page_url":"http:\/\/in10km:8000\/api\/listing\/stores?page=2",
"prev_page_url":null,
"from":1,
"to":1,
"data":[
{
"localstoreid":3,
"name":"cuddalore store",
"slug":"cuddalore-store",
"shortdescription":"",
"description":"",
"addressline1":"100,police line",
"addressline2":"center city",
"city":"cuddalore",
"state":"tamilnadu",
"cuntry":"india",
"zipcode":"607001",
"url":"http:\/\/in10km.com",
"latitude":"11.744699",
"longitude":"79.76802429999998",
"ownername":"sathish kumar",
"ownercontact":"95436161262",
"metatitle":"cuddalore",
"metakey":"cuddalore",
"metadesc":"cuddlore",
"verified":0,
"status":1,
"deletestatus":0,
"created_at":"2016-04-19 14:29:03",
"updated_at":"2016-04-19 14:29:03"
}
]
}
}
i need output like this in my json code next_page_url should be like api/listing/stores?category=category_name&page=2
i would get with url request also with paginate page value
Upvotes: 1
Views: 4695
Reputation: 35200
According to the docs: https://laravel.com/docs/5.1/pagination#displaying-results-in-a-view you can do the following:
$store_list->appends(['category' => 'category_name']);
Hope this helps!
Upvotes: 1