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

use common\components\FrontendController;
use common\modules\school\models\SearchCourses;
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(){
        \Yii::$app->view->registerMetaTag([
            'property' => 'og:title',
            'content' => 'Школа аналитики'
        ]);
        $searchModel  = new SearchCourses();
        $search = \Yii::$app->request->queryParams;

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

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