<?php



namespace chd7well\master\models;

use Yii;

/**
 * This is the model class for table "{{%master_modelname}}".
 *

 * @author Christian Dumhart <christian.dumhart@chd.at>
 */
class Modelname extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%master_modelname}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['modelname'], 'required'],
            [['modelname'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ID' => Yii::t('master', 'ID'),
            'modelname' => Yii::t('master', 'Model name'),
        ];
    }

    public static function getModelnameID($modelname)
    {
    	$model = Modelname::findOne(['modelname'=>$modelname]);
    	if(!isset($model) || $model == null)
    	{
    		$model = new Modelname();
    		$model->modelname = $modelname;
    		$model->save();
    	}
    	return $model->ID;
    }
    
}