73 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace common\models;
 | 
						|
 | 
						|
use Yii;
 | 
						|
 | 
						|
/**
 | 
						|
 * This is the model class for table "check_product".
 | 
						|
 *
 | 
						|
 * @property int $check_id
 | 
						|
 * @property int $product_id
 | 
						|
 * @property int|null $quantity
 | 
						|
 *
 | 
						|
 * @property Check $check
 | 
						|
 * @property Product $product
 | 
						|
 */
 | 
						|
class CheckProduct extends \yii\db\ActiveRecord
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public static function tableName()
 | 
						|
    {
 | 
						|
        return 'check_product';
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public function rules()
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            [['check_id', 'product_id'], 'required'],
 | 
						|
            [['check_id', 'product_id', 'quantity'], 'integer'],
 | 
						|
            [['check_id', 'product_id'], 'unique', 'targetAttribute' => ['check_id', 'product_id']],
 | 
						|
            [['check_id'], 'exist', 'skipOnError' => true, 'targetClass' => Check::class, 'targetAttribute' => ['check_id' => 'id']],
 | 
						|
            [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::class, 'targetAttribute' => ['product_id' => 'id']],
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * {@inheritdoc}
 | 
						|
     */
 | 
						|
    public function attributeLabels()
 | 
						|
    {
 | 
						|
        return [
 | 
						|
            'check_id' => 'Check ID',
 | 
						|
            'product_id' => 'Product ID',
 | 
						|
            'quantity' => 'Quantity',
 | 
						|
        ];
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Gets query for [[Check]].
 | 
						|
     *
 | 
						|
     * @return \yii\db\ActiveQuery
 | 
						|
     */
 | 
						|
    public function getCheck()
 | 
						|
    {
 | 
						|
        return $this->hasOne(Check::class, ['id' => 'check_id']);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Gets query for [[Product]].
 | 
						|
     *
 | 
						|
     * @return \yii\db\ActiveQuery
 | 
						|
     */
 | 
						|
    public function getProduct()
 | 
						|
    {
 | 
						|
        return $this->hasOne(Product::class, ['id' => 'product_id']);
 | 
						|
    }
 | 
						|
}
 |