How do you use paginate() in ci4 accompanied by query()
//situation
I am trying to use the paginate() accompanied with the query() but i get error messages i tried to do one with only the model using paginate(SETUP1). I also tried to do it with only the controller(SETUP2). But both give me the same error message
CodeIgniter\Database\MySQLi\Result::paginate()
!SETUP1
//PART OF MY CONTROLLER
$data["SearchData"] = $model->searchAll($sendData);
$data["pager"] = $model->pager;
//PART OF MY MODEL(It is inside the searchAll() function)
$query = $db->query($sql)->paginate(10);
$query->getResultArray();
$query->sql = $sql;
return $query;
//error
Call to undefined method CodeIgniter\Database\MySQLi\Result::paginate()
!SETUP2
//PART OF MY CONTROLLER
$data["SearchData"] = $model->searchAll($sendData)->paginate(10);
$data["pager"] = $model->pager;
//PART OF MY MODEL(It is inside the searchAll() function)
$query = $db->query($sql);
$query->getResultArray();
$query->sql = $sql;
return $query;
//(same)error
Call to undefined method CodeIgniter\Database\MySQLi\Result::paginate()
// How do I fix/make a workaround this error any suggestions/reccomendations/help will be appreciated thank you :) .