src/Entity/PaymentOrder.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Service\Helper\DateTimeHelper;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. /**
  8.  * @ORM\Table(name="orders__payments",
  9.  *     indexes={
  10.  *          @ORM\Index(name="created_at", columns={"created_at"}),
  11.  *     })
  12.  * @ORM\Entity(repositoryClass="App\Repository\PaymentOrderRepository")
  13.  */
  14. class PaymentOrder
  15. {
  16.     const ORDER_PAYMENT_TYPE_CASH 'cash';
  17.     const ORDER_PAYMENT_TYPE_TERMINAL 'terminal';
  18.     const ORDER_PAYMENT_TYPE_SBERBANK_SITE 'sberbank_site';
  19.     const ORDER_PAYMENT_TYPES = [
  20.         self::ORDER_PAYMENT_TYPE_CASH => 'наличными',
  21.         self::ORDER_PAYMENT_TYPE_TERMINAL => 'через терминал',
  22.         self::ORDER_PAYMENT_TYPE_SBERBANK_SITE => 'Сбербанк на сайте',
  23.     ];
  24.     use IdTrait;
  25.     /**
  26.      * @ORM\Column(name="created_at", type="datetime", nullable=false)
  27.      */
  28.     private DateTime $createdAt;
  29.     /**
  30.      * @ORM\Column(name="type", type="string", nullable=true)
  31.      */
  32.     private string $type;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity="App\Entity\Order", cascade={"all"})
  35.      * @ORM\JoinColumn(name="order_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  36.      */
  37.     private Order $order;
  38.     /**
  39.      * @ORM\Column(name="amount", type="integer")
  40.      */
  41.     private int $amount;
  42.     /**
  43.      * @throws Exception
  44.      */
  45.     public function __construct(
  46.         Order $order,
  47.         int $amount,
  48.         string $type
  49.     )
  50.     {
  51.         $this->createdAt DateTimeHelper::getNowDateTime();
  52.         $this->order $order;
  53.         $this->amount $amount;
  54.         $this->type $type;
  55.     }
  56.     public function getOrder(): Order
  57.     {
  58.         return $this->order;
  59.     }
  60.     public function getAmount(): int
  61.     {
  62.         return $this->amount;
  63.     }
  64.     public function getType(): string
  65.     {
  66.         return $this->type;
  67.     }
  68.     public function getCreatedAt(): DateTime
  69.     {
  70.         return $this->createdAt;
  71.     }
  72. }