<?php
/**
 * Created by PhpStorm.
 * User: PHOENIX
 * Date: 10.04.16
 * Time: 17:10
 */

namespace common\modules\analyticsSchool\controllers;


use common\components\AdminController;
use common\modules\analyticsSchool\models\AnalyticsSchoolLesson;
use yii\data\ActiveDataProvider;

class LessonAdminController extends AdminController {
    /**
     * @return array|void
     */
    public static function actionsTitles(){
        return [
            'Manage' => 'Управление уроками',
            'Create' => 'Добавление нового урока',
            'View'   => 'Просмотр урока',
            'Update' => 'Редактирование урока',
            'Delete' => 'Удаление урока',
        ];
    }

    /**
     * @return string
     */
    public function actionManage(){
        $dataProvider = new ActiveDataProvider([
            'query' => AnalyticsSchoolLesson::find(),
        ]);

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

    public function actionCreate(){
        $model = new AnalyticsSchoolLesson();
        if ($model->load(\Yii::$app->request->post())) {
            if ($model->validate() && $model->save())
                return $this->redirect([
                    'manage'
                ]);
        }
        $form = new \common\components\BaseForm('/common/modules/analyticsSchool/forms/LessonForm', $model);
        return $this->render(
            'create',
            [
                'form' => $form
            ]
        );
    }
} 