HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux dev1 5.15.83-1-pve #1 SMP PVE 5.15.83-1 (2022-12-15T00:00Z) x86_64
User: safarimaris (1000)
PHP: 7.2.34-54+ubuntu22.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /home/safarimaris/home/safarimaris/frontend/controllers/SearchController.php
<?php

namespace frontend\controllers;

use Yii;
use frontend\models\Search;
use yii\data\Pagination;
use common\components\EntityTypes;

class SearchController extends Controller
{
    public function actionIndex()
    {
        $secondSearch = false;
        $searchModel = new Search();
        $dataProvider = $searchModel->data();
        $monthYear = '';
        if(Yii::$app->request->get('ym')){
            $ym = Yii::$app->request->get('ym');
            if ($ym < date('Ym')) {
                $ym = date('Ym');
            }
            $monthYear = Yii::t('app', date('F', strtotime($ym.'01'))) . ' ' . date('Y', strtotime($ym.'01'));
            if($dataProvider->totalCount == 0){
                $secondSearch = true;
                $ym = date('Ym', strtotime($ym.'01 +1 month'));
                $dataProvider = $searchModel->data($ym);
            }
        }
        $dataProvider->pagination->pageSize=30;

        $pages = new Pagination(['totalCount' => 60]);
        $this->view->params['bodyClass'] = 'search-page';

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'secondSearch' => $secondSearch,
            'monthYear' => $monthYear,

            'filters' => $searchModel->getFilters(),
            'seoType' => EntityTypes::getActiveSeoName(Yii::$app->request->get('type')),
            'activeFilters' => $searchModel->getActiveFilters(),
            'when' => $searchModel->getCalendar(),
            'where' => $searchModel->getGeoGroups(),
            'pages' => $pages
        ]);

    }

    public function actionSuggest()
    {
        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
        //if (Yii::$app->request->isAjax) {
        $searchModel = new Search();
        return $searchModel->suggest();
        //}

    }

}