MarginsImporters.php 1.39 KB
<?php

namespace common\models;

use Yii;
use backend\models\Importers;

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

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['importer_id', 'margin_id', 'koef'], 'required'],
            [['importer_id', 'margin_id'], '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' => 'Коэффициент',
        ];
    }

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

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