Код: Выделить всё
<form method="get" action="<?php echo Url::to(['history/result']) ?>">
<div class="form-group">
<label for="exampleInputEmail1">Поиск по фамилии</label>
<input type="text" class="form-control" name="q" placeholder="Введите вашу фамилию">
</div>
<button type="submit" class="btn btn-primary">Найти</button>
</form>
Код: Выделить всё
public function actionResult()
{
$q = Yii::$app->request->get('q', 'submit');
if (!$q) {
return $this->render('result');
}
$query = Requests::find()->where(['like', 'fio', $q]);
$pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 10, 'forcePageParam' => false, 'pageSizeParam' => false]);
$result = $query->offset($pages->offset)->limit($pages->limit)->all();
return $this->render('result', compact('result', 'pages', 'q', 'submit'));
}