mercredi 20 avril 2016

pagination on rest api in laravel 5.1 with in request url

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire