HostFreeController.php 1.42 KB
<?php

namespace app\controllers;

use Yii;
use app\models\Host;
use app\models\HostSearch;
use app\models\Filter;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

/**
 * HostController implements the CRUD actions for Host model.
 */
class HostFreeController extends Controller
{
    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }

    /**
     * Lists all Host models.
     * @return mixed
     */
    public function actionIndex()
    {
        /*'wis_status' => Host::STATUS_WIS_FREE, 'status' => Filter::STATUS_ON */
        $params = Yii::$app->request->queryParams;
        $params['wis_status']=Host::STATUS_WIS_FREE;
        $searchModel = new HostSearch();
        $dataProvider = $searchModel->search($params);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }


}