|
- <?php
-
-
-
- namespace domain\Distribution\ProductDistribution;
-
- use common\components\ActiveRecordCommon;
- use domain\Distribution\Distribution\Distribution;
- use domain\Product\Product\Product;
-
- class ProductDistribution extends ActiveRecordCommon
- {
-
-
- public static function tableName()
- {
- return 'product_distribution';
- }
-
-
-
- public function rules()
- {
- return [
- [['id_distribution', 'id_product', 'active'], 'integer'],
- [['quantity_max'], 'number'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'id_distribution' => 'Distribution',
- 'id_product' => 'Produit',
- 'active' => 'Actif',
- 'quantity_max' => 'Quantité max',
- ];
- }
-
-
-
-
- public function getProduct()
- {
- return $this->hasOne(Product::class, ['id' => 'id_product']);
- }
-
- public function populateProduct(Product $product): void
- {
- $this->populateFieldObject('id_product', 'product', $product);
- }
-
- public function getDistribution()
- {
- return $this->hasOne(Distribution::class, ['id' => 'id_distribution']);
- }
-
- public function populateDistribution(Distribution $distribution): void
- {
- $this->populateFieldObject('id_distribution', 'distribution', $distribution);
- }
- }
|