|
- <?php
-
- namespace domain\PointSale\SharedPointSale;
-
- use common\components\ActiveRecordCommon;
- use domain\PointSale\PointSale\PointSale;
- use domain\Producer\Producer\Producer;
- use domain\User\User\User;
-
- class SharedPointSale extends ActiveRecordCommon
- {
- public function getPointSale(): PointSale
- {
- return $this->pointSaleRelation;
- }
-
- public function setPointSale(PointSale $pointSale): self
- {
- $this->populateFieldObject('id_point_sale', 'pointSaleRelation', $pointSale);
- return $this;
- }
-
- public function getProducerWithSharing(): Producer
- {
- return $this->producerWithSharingRelation;
- }
-
- public function setProducerWithSharing(Producer $producerWithSharing): self
- {
- $this->populateFieldObject('id_producer_with_sharing', 'producerWithSharingRelation', $producerWithSharing);
-
- return $this;
- }
-
- public function getPointSaleWithSharing(): ?PointSale
- {
- return $this->pointSaleWithSharing;
- }
-
- public function setPointSaleWithSharing(PointSale $pointSaleWithSharing = null): self
- {
- if($pointSaleWithSharing) {
- $this->populateFieldObject('id_point_sale_with_sharing', 'pointSaleWithSharingRelation', $pointSaleWithSharing);
- }
-
- return $this;
- }
-
- public function getStatus(): int
- {
- return $this->status;
- }
-
- public function setStatus(int $status): self
- {
- $this->status = $status;
- return $this;
- }
-
- public function getCreatedAt(): \DateTime
- {
- return new \DateTime($this->created_at);
- }
-
- public function setCreatedAt(\DateTime $createdAt): self
- {
- $this->created_at = $createdAt->format('Y-m-d H:i:s');
- return $this;
- }
-
- public function getConfirmedAt(): \DateTime
- {
- return new \DateTime($this->confirmed_at);
- }
-
- public function setConfirmedAt(\DateTime $confirmedAt): self
- {
- $this->confirmed_at = $confirmedAt->format('Y-m-d H:i:s');
- return $this;
- }
-
- public function getDeclinedAt(): \DateTime
- {
- return new \DateTime($this->declined_at);
- }
-
- public function setDeclinedAt(\DateTime $declinedAt): self
- {
- $this->declined_at = $declinedAt->format('Y-m-d H:i:s');
- return $this;
- }
-
- public function getCreatedBy(): User
- {
- return $this->createdByRelation;
- }
-
- public function setCreatedBy(User $createdBy): SharedPointSale
- {
- $this->populateFieldObject('created_by', 'createdByRelation', $createdBy);
- return $this;
- }
-
- public function getConfirmedBy(): User
- {
- return $this->confirmedByRelation;
- }
-
- public function setConfirmedBy(User $confirmedBy): SharedPointSale
- {
- $this->populateFieldObject('confirmed_by', 'confirmedByRelation', $confirmedBy);
- return $this;
- }
-
- public function getDeclinedBy(): User
- {
- return $this->declinedByRelation;
- }
-
- public function setDeclinedBy(User $declinedBy): SharedPointSale
- {
- $this->populateFieldObject('declined_by', 'declinedByRelation', $declinedBy);
- return $this;
- }
-
- public static function tableName()
- {
- return 'shared_point_sale';
- }
-
- public function rules()
- {
- return [
- [['id_point_sale', 'id_producer_with_sharing', 'created_at', 'created_by'], 'required'],
- [['id_point_sale', 'id_producer_with_sharing', 'id_point_sale_with_sharing', 'status',
- 'created_by', 'confirmed_by', 'declined_by'], 'integer'],
- [['created_at', 'confirmed_at', 'declined_at'], 'safe'],
- ['id_point_sale', 'exist', 'targetClass' => PointSale::class, 'targetAttribute' => 'id'],
- ['id_producer_with_sharing', 'exist', 'targetClass' => Producer::class, 'targetAttribute' => 'id'],
- [['created_by', 'confirmed_by', 'declined_by'], 'exist', 'targetClass' => User::class, 'targetAttribute' => 'id'],
- ];
- }
-
- public function attributeLabels()
- {
- return [
- 'id_point_sale' => 'Point de vente que vous souhaitez partager',
- 'id_producer_with_sharing' => 'Producteur avec qui vous souhaitez partager un point de vente',
- 'id_point_sale_with_sharing' => 'Point de vente du producteur avec qui vous souhaitez partager ce point de vente',
- ];
- }
-
- /* Relations */
-
- public function getPointSaleRelation()
- {
- return $this->hasOne(PointSale::class, ['id' => 'id_point_sale']);
- }
-
- public function getProducerWithSharingRelation()
- {
- return $this->hasOne(Producer::class, ['id' => 'id_producer_with_sharing']);
- }
-
- public function getPointSaleWithSharingRelation()
- {
- return $this->hasOne(PointSale::class, ['id' => 'id_point_sale_with_sharing']);
- }
-
- public function getCreatedByRelation()
- {
- return $this->hasOne(User::class, ['id' => 'created_by']);
- }
-
- public function getConfirmedByRelation()
- {
- return $this->hasOne(User::class, ['id' => 'confirmed_by']);
- }
-
- public function getDeclinedByRelation()
- {
- return $this->hasOne(User::class, ['id' => 'declined_by']);
- }
- }
|