|
- <?php
-
-
-
- namespace domain\Distribution\Distribution;
-
- use common\components\ActiveRecordCommon;
- use domain\Distribution\PointSaleDistribution\PointSaleDistribution;
- use domain\Distribution\ProductDistribution\ProductDistribution;
- use domain\Order\Order\Order;
- use domain\Producer\Producer\Producer;
-
- class Distribution extends ActiveRecordCommon
- {
- const EVENT_ACTIVE = 'distribution.event.active';
-
-
-
- public static function tableName()
- {
- return 'distribution';
- }
-
-
-
- public function rules()
- {
- return [
- [['date'], 'required'],
- [['active'], 'integer'],
- [['date'], 'safe'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'date' => 'Date',
- 'active' => 'Actif',
- ];
- }
-
-
-
-
- public function getProducer()
- {
- return $this->hasOne(Producer::class, ['id' => 'id_producer']);
- }
-
- public function populateProducer(Producer $producer): void
- {
- $this->populateFieldObject('id_producer', 'producer', $producer);
- }
-
- public function getOrder()
- {
- return $this->hasMany(Order::class, ['id_distribution' => 'id']);
- }
-
- public function getProductDistribution()
- {
- return $this->hasMany(ProductDistribution::class, ['id_distribution' => 'id']);
- }
-
- public function getPointSaleDistribution()
- {
- return $this->hasMany(PointSaleDistribution::class, ['id_distribution' => 'id']);
- }
- }
|