Commit fb9886c5f538c5adff98d8d53cdbaf84d71ab0bd
1 parent
54ef9eb4
big commti
Showing
1 changed file
with
68 additions
and
0 deletions
Show diff stats
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace common\models; | ||
| 4 | + | ||
| 5 | +use common\modules\product\models\Product; | ||
| 6 | +use Yii; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * This is the model class for table "events_to_products". | ||
| 10 | + * | ||
| 11 | + * @property integer $events_to_products_id | ||
| 12 | + * @property integer $event_id | ||
| 13 | + * @property integer $product_id | ||
| 14 | + * | ||
| 15 | + * @property Event $event | ||
| 16 | + * @property Product $product | ||
| 17 | + */ | ||
| 18 | +class EventsToProducts extends \yii\db\ActiveRecord | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * @inheritdoc | ||
| 22 | + */ | ||
| 23 | + public static function tableName() | ||
| 24 | + { | ||
| 25 | + return 'events_to_products'; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @inheritdoc | ||
| 30 | + */ | ||
| 31 | + public function rules() | ||
| 32 | + { | ||
| 33 | + return [ | ||
| 34 | + [['event_id', 'product_id'], 'required'], | ||
| 35 | + [['event_id', 'product_id'], 'integer'], | ||
| 36 | + [['event_id'], 'exist', 'skipOnError' => true, 'targetClass' => Event::className(), 'targetAttribute' => ['event_id' => 'event_id']], | ||
| 37 | + [['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::className(), 'targetAttribute' => ['product_id' => 'product_id']], | ||
| 38 | + ]; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @inheritdoc | ||
| 43 | + */ | ||
| 44 | + public function attributeLabels() | ||
| 45 | + { | ||
| 46 | + return [ | ||
| 47 | + 'events_to_products_id' => 'Events To Products ID', | ||
| 48 | + 'event_id' => 'Event ID', | ||
| 49 | + 'product_id' => 'Product ID', | ||
| 50 | + ]; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * @return \yii\db\ActiveQuery | ||
| 55 | + */ | ||
| 56 | + public function getEvent() | ||
| 57 | + { | ||
| 58 | + return $this->hasOne(Event::className(), ['event_id' => 'event_id']); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * @return \yii\db\ActiveQuery | ||
| 63 | + */ | ||
| 64 | + public function getProduct() | ||
| 65 | + { | ||
| 66 | + return $this->hasOne(Product::className(), ['product_id' => 'product_id']); | ||
| 67 | + } | ||
| 68 | +} |