<?php

namespace common\modules\analyticsSchool\models;

use Yii;

/**
 * This is the model class for table "analytics_school_lesson_file".
 *
 * @property integer $id
 * @property integer $lesson_id
 * @property string $title
 * @property string $file
 *
 * @property AnalyticsSchoolLesson $lesson
 */
class AnalyticsSchoolLessonFile extends \yii\db\ActiveRecord
{
    public $document;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'analytics_school_lesson_file';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['lesson_id', 'title', 'file'], 'required'],
            [['lesson_id'], 'integer'],
            [['file'], 'string'],
            [['title'], 'string', 'max' => 255],
            [['document'], 'file', 'extensions' => 'PDF, RAR, ZIP, DOC. XLS, PPT'],
            [['lesson_id'], 'exist', 'skipOnError' => true, 'targetClass' => AnalyticsSchoolLesson::className(), 'targetAttribute' => ['lesson_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'lesson_id' => 'Lesson ID',
            'title' => 'Title',
            'file' => 'File',
        ];
    }

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