Commit f042e1caff13e18c06f19f6007b65c80b8e8debd

Authored by Alexey Boroda
2 parents 01185786 7d401cbd

Merge remote-tracking branch 'origin/master'

Showing 1 changed file with 15 additions and 1 deletions   Show diff stats
models/Product.php
... ... @@ -8,6 +8,7 @@
8 8 use artweb\artbox\ecommerce\behaviors\DefaultVariantBehavior;
9 9 use artweb\artbox\behaviors\MultipleImgBehavior;
10 10 use artweb\artbox\behaviors\SaveMultipleFileBehavior;
  11 + use artweb\artbox\event\models\Event;
11 12 use artweb\artbox\language\behaviors\LanguageBehavior;
12 13 use Yii;
13 14 use yii\base\InvalidParamException;
... ... @@ -274,7 +275,20 @@
274 275 {
275 276 return $this->getVariant();
276 277 }
277   -
  278 +
  279 +
  280 +
  281 +
  282 +
  283 + /**
  284 + * @return \yii\db\ActiveQuery
  285 + */
  286 + public function getEvents(){
  287 + return $this->hasMany(Event::className(), ['id' => 'event_id'])->viaTable('events_to_products', ['product_id' => 'id'])->where(['status'=>Event::ACTIVE]);
  288 + }
  289 +
  290 +
  291 +
278 292 /**
279 293 * Get ProductVariant query fetching only available in stock to current Product
280 294 *
... ...