<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "fix_metal_level".
 *
 * @property integer $id
 * @property string $name
 * @property integer $level
 * @property string $created_at
 * @property string $updated_at
 */
class FixMetalLevel extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'fix_metal_level';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'level'], 'required'],
            [['level'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['name'], 'string', 'max' => 5],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'level' => 'Level',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
    public function getFixCarMetals(){
        return $this->hasMany(FixCarMetal::className(),['level_id'=>'id']);
    }
    public function getProject(){
        return $this->hasMany(FixCarProject::className(),['id'=>'project_id'])
            ->via('fixCarMetals');
    }
}
