<?php

namespace common\modules\analyticsSchool\models;

use Yii;

/**
 * This is the model class for table "analytics_school_lessons".
 *
 * @property integer $id
 * @property integer $course_id
 * @property string $name
 * @property string $video_link
 * @property string $content
 *
 * @property AnalyticsSchoolCourse $course
 */
class AnalyticsSchoolLesson extends \common\components\ActiveRecordModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'analytics_school_lesson';
    }

    /**
     * @return string
     */
    public function name(){
        return 'Уроки';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['course_id', 'name', 'content'], 'required'],
            [['course_id'], 'integer'],
            [['video_link', 'content'], 'string'],
            [['name'], 'string', 'max' => 255],
            [['course_id'], 'exist', 'skipOnError' => true, 'targetClass' => AnalyticsSchoolCourse::className(), 'targetAttribute' => ['course_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'course_id' => 'Курс',
            'name' => 'Название урока',
            'video_link' => 'Ссылка на видео',
            'content' => 'Материал урока',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCourse() {
        return $this->hasOne(AnalyticsSchoolCourse::className(), ['id' => 'course_id']);
    }

    /**
     * @return array
     */
    public function behaviors(){
        return [];
    }
}
