<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "article_to_rating".
 *
 * @property integer $article_to_rating_id
 * @property integer $articles_id
 * @property double $value
 *
 * @property Articles $articles
 */
class ArticleToRating extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'article_to_rating';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['articles_id'], 'required'],
            [['articles_id'], 'integer'],
            [['value'], 'number'],
            [['articles_id'], 'exist', 'skipOnError' => true, 'targetClass' => Articles::className(), 'targetAttribute' => ['articles_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'article_to_rating_id' => 'Article To Rating ID',
            'articles_id' => 'Articles ID',
            'value' => 'Value',
        ];
    }

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