I am new to laravel4, I am working basically with SOAP webservices in laravel 4 using Nusoap library.
My problem is with pagination, at controller my code is ast follow
function AjaxProductList()
{
$isAjax = Request::ajax();
if($isAjax)
{
//instantiate the NuSOAP class and define the web service URL:
$client = new nusoap_client('http://stage.ws.greenbook.net/gbwswcf/servicegb.svc?wsdl', 'WSDL');
//check if there were any instantiation errors, and if so stop execution with an error message:
$error = $client->getError();
if ($error) {
die("client construction error: {$error}
");
}
if(Input::get('term'))
{
Session::put('term', Input::get('term'));
$term = Input::get('term');
}
else
$term = Session::get('term');
if(Input::get('pg_number')!='')
{
Session::put('page_num', Input::get('pg_number'));
$page_num = Input::get('pg_number');
}
else
$page_num = Session::get('page_num');
if(Input::get('per_pg_result') !='')
{
Session::put('result_per_page', Input::get('per_pg_result'));
$result_per_page = Input::get('per_pg_result');
}
else
$result_per_page = Session::get('result_per_page');
$param = 'SearchParam=|category@'.Session::get('type').'|searchterm@'.$term;
//$value = Session::get('key');
$params = array( 'ClientID' => Config::get('globals.ClientID'),
'strPwd' => Config::get('globals.password'),
'Params' => $param ,
'PageNum' =>$page_num,
'NumOfResultsPerPage' =>$result_per_page
);
$client->soap_defencoding = 'UTF-8';
$answer = $client->call('GetResultsV2',$params);
//check if there were any call errors, and if so stop execution with some error messages:
$error = $client->getError();
if ($error) {
echo 'some error occured , please try again later';
die();
}
$ResultNumbers = Common::find_key_array('ResultNumbers',$answer);
$data['SearchParams'] = Common::find_key_array('SearchParams',$answer);
$data['products'] = Common::find_key_array('Product',$answer);
$data['total_result'] = $ResultNumbers['TotalNum'];
$data['paginator'] = **Paginator::make($data['products'],$data['total_result'],$result_per_page)**;
$return["prd_listing_bot"] = View::make('frontend.search.ajax_product_listing',$data)->render();
echo json_encode($return);
exit;
}
else
{
echo 'not allowed';
}
}
here i am using Paginatior class and providing the parameters (returned records,total items,perpage items).
here is my view code:
$paginator->setBaseUrl('search');
echo $paginator->links();
NOW its creating links successfully
My URL structure after clicking 5 is
'http://mydomain/search?page=5'.
and in 'routes.php' i have
Route::any('search', array('uses' => 'SearchController@QuickSearch'));
when the page view is loaded an ajax call is initiated for function AjaxProductList();
when i click on any link in pagination, it fatches data successfully, but not updating the active link. i.e if i click on page number 5 it will fetch the correct data but active link will be still at page "1".
tell me please if i am doing anything wrong?
thanks in advance.