/** * @inheritdoc */ public function rules() { return [[['product_id', 'created_at'], 'required'], [['product_id', 'receipt_id'], 'integer'], [['price'], 'number'], [['created_at', 'updated_at'], 'safe'], [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'id']], [['receipt_id'], 'exist', 'skipOnError' => true, 'targetClass' => Receipt::className(), 'targetAttribute' => ['receipt_id' => 'id']]]; }
/** * @return \yii\db\ActiveQuery */ public function getReceipts() { return $this->hasMany(Receipt::className(), ['shop_id' => 'id']); }