I'm new to Codeigniter pagination so i'm not able to configure it properly, that why i need your help guys.
This is my code so far
public function nearbay_get($idNearBay = null)
{
$config['base_url'] = 'http://mypage.si/rest/api/nearbay/nearbay';
$config['total_rows'] = $this->Near_bays->count();
$config["per_page"] = 5;
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$config['suffix'] = '?'.http_build_query($_GET, '', "&");
$config['use_page_numbers'] = TRUE;
$config['enable_query_strings'] = 'page=';
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = round($choice);
$this->pagination->initialize($config);
$page = ($this->uri->segment(6))? $this->uri->segment(6) : 0;
$results = $this->Near_bays->get(null, [null, null], [null, null], '', $config["per_page"], $page);
foreach($results as $data) {
echo $data->id_near_bay . " ------- " . $data->name . "<br>";
}
echo $this->pagination->create_links();
}
And this is the result if i visit http://mypage.si/rest/api/nearbay/nearbay
And if i click on any page number i get blank page and my url changes to http://mypage.si/rest/api/nearbay/nearbay?

So my question are. How to get pagination working? How to properly config pagination so i will be able to fetch results via ?page and ?per_page values trough url.. My final links should look like this http://mypage.si/rest/api/nearbay/nearbay?page=1&per_page=20
If you need any additional informations please let me know and i will provide... Thank you!