MarginsImportersImport.php 1.5 KB
<?php

namespace common\models;

use backend\models\Importers;
use Yii;

/**
 * This is the model class for table "w_margins_importers_import".
 *
 * @property integer $id
 * @property integer $importer_id
 * @property integer $margin_id
 * @property double $koef
 * @property integer $finish
 */
class MarginsImportersImport extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'w_margins_importers_import';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['importer_id', 'margin_id', 'koef', 'finish'], 'required'],
            [['importer_id', 'margin_id', 'finish'], 'integer'],
            [['koef'], 'number'],
            [['importer_id', 'margin_id'], 'unique', 'targetAttribute' => ['importer_id', 'margin_id'], 'message' => 'The combination of Importer ID and Margin ID has already been taken.']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'importer_id' => 'Поставщик',
            'margin_id' => 'Тип цены',
            'koef' => 'Коэффициент',
            'finish' => 'Активно',
        ];
    }

    public function getImporters()
    {
        return $this->hasOne(Importers::className(), ['id' => 'importer_id']);
    }

    public function getMargins()
    {
        return $this->hasOne(Margins::className(), ['id' => 'margin_id']);
    }
}