Please help, i’m beginner. I have an error “__clone method called on non-object”
I have KomentarController.php
public function actionTampil()
{
$query = Komentar::find()->all();
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countModels->count()]);
$models = $query->offset($pages->offset)
->limit($pages->limit)
->all();
return $this->render('tampil', [
'models' => $models,
'pages' => $pages,
]);
}
and view on tampil.php
use yii\helpers\Html;
use yii\widgets\LinkPager;
foreach ($models as $key => $model) {
echo LinkPager::widget([
'pagination' => $pages,
]);
}