Fields.php 1.21 KB
<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "{{%fields}}".
 *
 * @property integer $id
 * @property string $table_name
 * @property integer $table_id
 * @property string $value
 * @property string $field_name
 * @property string $field_type
 */
class Fields extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%fields}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['table_name', 'table_id',], 'required'],
            [['table_id','language'], 'integer'],
            [['table_name', 'value', 'field_name','field_type'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'table_name' => 'Model Name',
            'table_id' => 'Model ID',
            'value' => 'Value',
            'field_name' => 'Field Name',
            'language' => 'Language',
        ];
    }

    public static function getData($id, $model, $type){
       return self::find()->where(['table_id'=>$id, 'table_name'=>$model, 'field_type'=>$type])->all();
    }
}