public function actionIndex() {
$query = Users::find();
$start = \Yii::$app->request->get('start');
$limit = \Yii::$app->request->get('length');
$pagination = new Pagination([
'totalCount' => $query->count(),
]);
$users['data'] = $query->offset($start)
->limit($limit)
->all();
$users['recordsTotal'] = $pagination->totalCount;
$users['recordsFiltered'] = $pagination->totalCount;
return $users;
}
Model::find()->offset($start)->limit($limit)
Find more questions by tags RESTful APIYii
{
$query = Users::find();
$pagination = new Pagination([
'defaultPageSize' => 10,
'totalCount' => $query->count(),
'pageSizeParam' => 'start',
]);
$users['data'] = $query->offset($pagination->offset)
->limit($pagination->limit)
->all();
return $users;
}
How do I catch the parameters passed to the GET request from the client. - Martina_Corkery commented on July 8th 19 at 15:41