|
- <?php
-
-
-
- namespace domain\Payment;
-
- use common\components\ActiveRecordCommon;
- use domain\Document\Invoice\Invoice;
- use domain\Order\Order\Order;
- use domain\Producer\Producer\Producer;
- use domain\User\User\User;
- use yii\db\ActiveQuery;
-
- class Payment extends ActiveRecordCommon
- {
- const TYPE_INITIAL_CREDIT = 'initial-credit';
- const TYPE_CREDIT = 'credit';
- const TYPE_PAYMENT = 'payment';
- const TYPE_REFUND = 'refund';
- const TYPE_DEBIT = 'debit';
-
-
-
- public static function tableName(): string
- {
- return 'payment';
- }
-
-
-
- public function rules(): array
- {
- return [
- [['amount'], 'required'],
- [['id_user', 'id_user_action', 'id_order', 'id_invoice', 'id_producer'], 'integer'],
- [['date'], 'safe'],
- [['amount'], 'double'],
- [['date_transaction'], 'date', 'format' => 'php:Y-m-d'],
- [['type', 'mean_payment'], 'string', 'max' => 255],
- [['comment', 'summary'], 'string', 'max' => 2048],
- ];
- }
-
-
-
- public function attributeLabels(): array
- {
- return [
- 'id' => 'ID',
- 'id_user' => 'Utilisateur',
- 'id_user_action' => 'Utilisateur',
- 'id_order' => 'Commande',
- 'id_invoice' => 'Facture',
- 'date' => 'Date',
- 'amount' => 'Montant',
- 'type' => 'Type',
- 'id_producer' => 'Producteur',
- 'mean_payment' => 'Moyen de paiement',
- 'comment' => 'Commentaire',
- 'summary' => 'Résumé',
- 'date_transaction' => 'Date transaction'
- ];
- }
-
-
-
-
- public function getProducer(): ActiveQuery
- {
- return $this->hasOne(Producer::class, ['id' => 'id_producer']);
- }
-
- public function populateProducer(Producer $producer): void
- {
- $this->populateFieldObject('id_producer', 'producer', $producer);
- }
-
- public function getUser(): ActiveQuery
- {
- return $this->hasOne(User::class, ['id' => 'id_user']);
- }
-
- public function populateUser(User $user): void
- {
- $this->populateFieldObject('id_user', 'user', $user);
- }
-
- public function getUserObject(): ?User
- {
- return $this->user;
- }
-
- public function getUserAction(): ActiveQuery
- {
- return $this->hasOne(User::class, ['id' => 'id_user_action']);
- }
-
- public function populateUserAction(User $user): void
- {
- $this->populateFieldObject('id_user_action', 'userAction', $user);
- }
-
- public function getUserActionObject(): ?User
- {
- return $this->userAction;
- }
-
- public function getOrder(): ActiveQuery
- {
- return $this->hasOne(Order::class, ['id' => 'id_order']);
- }
-
- public function populateOrder(Order $order): void
- {
- $this->populateFieldObject('id_order', 'order', $order);
- }
-
- public function getOrderObject(): ?Order
- {
- return $this->order;
- }
-
- public function getInvoice(): ActiveQuery
- {
- return $this->hasOne(Invoice::class, ['id' => 'id_invoice']);
- }
-
- public function populateInvoice(Invoice $invoice): void
- {
- $this->populateFieldObject('id_invoice', 'invoice', $invoice);
- }
-
- public function getInvoiceObject(): ?Invoice
- {
- return $this->invoice;
- }
-
-
-
-
- public function getId(): int
- {
- return $this->id;
- }
-
- public function getIdUser(): ?int
- {
- return $this->id_user;
- }
-
- public function setIdUser(?int $idUser): self
- {
- $this->id_user = $idUser;
-
- return $this;
- }
-
- public function getIdUserAction(): ?int
- {
- return $this->id_user_action;
- }
-
- public function setIdUserAction(?int $idUserAction): self
- {
- $this->id_user_action = $idUserAction;
-
- return $this;
- }
-
- public function getIdOrder(): ?int
- {
- return $this->id_order;
- }
-
- public function setIdOrder(?int $idOrder): self
- {
- $this->id_order = $idOrder;
-
- return $this;
- }
-
- public function getDate(): ?string
- {
- return $this->date;
- }
-
- public function setDate(?string $date): self
- {
- $this->date = $date;
-
- return $this;
- }
-
- public function getAmount(): ?float
- {
- return $this->amount;
- }
-
- public function setAmount(?float $amount): self
- {
- $this->amount = $amount;
-
- return $this;
- }
-
- public function getType(): ?string
- {
- return $this->type;
- }
-
- public function setType(?string $type): self
- {
- $this->type = $type;
-
- return $this;
- }
-
- public function getIdProducer(): ?int
- {
- return $this->id_producer;
- }
-
- public function setIdProducer(?int $idProducer): self
- {
- $this->id_producer = $idProducer;
-
- return $this;
- }
-
- public function getMeanPayment(): ?string
- {
- return $this->mean_payment;
- }
-
- public function setMeanPayment(?string $meanPayment): self
- {
- $this->mean_payment = $meanPayment;
-
- return $this;
- }
-
- public function getComment(): ?string
- {
- return $this->comment;
- }
-
- public function setComment(?string $comment): self
- {
- $this->comment = $comment;
-
- return $this;
- }
-
- public function setDateTransaction(?string $dateTransaction): self
- {
- $this->date_transaction = $dateTransaction;
-
- return $this;
- }
-
- public function getSummary(): ?string
- {
- return $this->summary;
- }
-
- public function setSummary(?string $summary): self
- {
- $this->summary = $summary;
-
- return $this;
- }
- }
|