<?php
namespace common\modules\analyticsSchool\controllers;

use common\components\FrontendController;
use common\modules\analyticsSchool\models\CoursesSearch;
use yii\filters\AccessControl;

class CourseController extends FrontendController {

    public static function actionsTitles() {
        return [
            'Index'  => 'Школа аналитики'
        ];
    }

    public function behaviors() {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'user' => 'support',
                'only' => ['view', 'index'],
                'rules' => [
                    [
                        'allow' => true,
                        'actions' => ['view', 'index'],
                        'roles' => ['?'],
                    ],
                ],
            ],
        ];
    }

    public function actionIndex(){
        $searchModel  = new CoursesSearch();
        $search = \Yii::$app->request->queryParams;

        $dataProvider = $searchModel->search($search);

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