Answer the question
In order to leave comments, you need to log in
How to get an array of data from a Request using Yii2 methods according to certain rules?
To perform a specific operation, you need to get an array of parameters from a (get) request.
page: unsigned integer (default 1)
per_page: unsigned integer from the set (4,12,24,48), default - 4
skip: unsigned integer (default 1)
You can, of course, do everything manually using self-written functions type
$request = prepareArray('page,per_page,skip', true); // Получить именованный массив из request
$request['page'] = max(1, intval($request['page']));
$request['per_page'] = checkEnum($request['per_page'], '4,12,24,48');
$request['skip'] = abs(intval($request['skip']));
Answer the question
In order to leave comments, you need to log in
For myself, I solved the issue with the help of a model and custom validators.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question