src/Entity/Account.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AccountRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=AccountRepository::class)
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Account
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=Bank::class, inversedBy="accounts")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private $bank;
  24.     /**
  25.      * @ORM\ManyToOne(targetEntity=Province::class)
  26.      * @ORM\JoinColumn(nullable=true)
  27.      */
  28.     private $province;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Territoire::class)
  31.      * @ORM\JoinColumn(nullable=true)
  32.      */
  33.     private $territoire;
  34.     /**
  35.      * @ORM\Column(type="string", length=100, unique=true)
  36.      */
  37.     private $accountNumber;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      */
  41.     private $accountName;
  42.     /**
  43.      * @ORM\Column(type="string", length=20, nullable=true)
  44.      */
  45.     private $accountingNumber;
  46.     /**
  47.      * @ORM\Column(type="string", length=3, options={"default": "USD"})
  48.      */
  49.     private $currency 'USD';
  50.     /**
  51.      * @ORM\Column(type="boolean", options={"default": true})
  52.      */
  53.     private $isActive true;
  54.     /**
  55.      * @ORM\Column(type="boolean", options={"default": true})
  56.      */
  57.     private $isAvailableForPayment true;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=AccountHistory::class, mappedBy="account", cascade={"persist", "remove"})
  60.      */
  61.     private $history;
  62.     /**
  63.      * @ORM\Column(type="datetime")
  64.      */
  65.     private $createdAt;
  66.     /**
  67.      * @ORM\Column(type="datetime", nullable=true)
  68.      */
  69.     private $updatedAt;
  70.     public function __construct()
  71.     {
  72.         $this->createdAt = new \DateTime();
  73.         $this->isActive true;
  74.         $this->isAvailableForPayment true;
  75.         $this->currency 'USD';
  76.         $this->history = new ArrayCollection();
  77.     }
  78.     /**
  79.      * @ORM\PreUpdate
  80.      */
  81.     public function setUpdatedAtValue(): void
  82.     {
  83.         $this->updatedAt = new \DateTime();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getBank(): ?Bank
  90.     {
  91.         return $this->bank;
  92.     }
  93.     public function setBank(?Bank $bank): self
  94.     {
  95.         $this->bank $bank;
  96.         return $this;
  97.     }
  98.     public function getProvince(): ?Province
  99.     {
  100.         return $this->province;
  101.     }
  102.     public function setProvince(?Province $province): self
  103.     {
  104.         $this->province $province;
  105.         return $this;
  106.     }
  107.     public function getTerritoire(): ?Territoire
  108.     {
  109.         return $this->territoire;
  110.     }
  111.     public function setTerritoire(?Territoire $territoire): self
  112.     {
  113.         $this->territoire $territoire;
  114.         return $this;
  115.     }
  116.     public function getAccountNumber(): ?string
  117.     {
  118.         return $this->accountNumber;
  119.     }
  120.     public function setAccountNumber(string $accountNumber): self
  121.     {
  122.         $this->accountNumber $accountNumber;
  123.         return $this;
  124.     }
  125.     public function getAccountName(): ?string
  126.     {
  127.         return $this->accountName;
  128.     }
  129.     public function setAccountName(string $accountName): self
  130.     {
  131.         $this->accountName $accountName;
  132.         return $this;
  133.     }
  134.     public function getAccountingNumber(): ?string
  135.     {
  136.         return $this->accountingNumber;
  137.     }
  138.     public function setAccountingNumber(?string $accountingNumber): self
  139.     {
  140.         $this->accountingNumber $accountingNumber;
  141.         return $this;
  142.     }
  143.     public function getCurrency(): ?string
  144.     {
  145.         return $this->currency;
  146.     }
  147.     public function setCurrency(string $currency): self
  148.     {
  149.         $this->currency $currency;
  150.         return $this;
  151.     }
  152.     public function getIsActive(): ?bool
  153.     {
  154.         return $this->isActive;
  155.     }
  156.     public function setIsActive(bool $isActive): self
  157.     {
  158.         $this->isActive $isActive;
  159.         return $this;
  160.     }
  161.     public function getIsAvailableForPayment(): ?bool
  162.     {
  163.         return $this->isAvailableForPayment;
  164.     }
  165.     public function setIsAvailableForPayment(bool $isAvailableForPayment): self
  166.     {
  167.         $this->isAvailableForPayment $isAvailableForPayment;
  168.         return $this;
  169.     }
  170.     /**
  171.      * @return Collection|AccountHistory[]
  172.      */
  173.     public function getHistory(): Collection
  174.     {
  175.         return $this->history;
  176.     }
  177.     public function addHistory(AccountHistory $history): self
  178.     {
  179.         if (!$this->history->contains($history)) {
  180.             $this->history[] = $history;
  181.             $history->setAccount($this);
  182.         }
  183.         return $this;
  184.     }
  185.     public function removeHistory(AccountHistory $history): self
  186.     {
  187.         if ($this->history->removeElement($history)) {
  188.             if ($history->getAccount() === $this) {
  189.                 $history->setAccount(null);
  190.             }
  191.         }
  192.         return $this;
  193.     }
  194.     public function getCreatedAt(): ?\DateTimeInterface
  195.     {
  196.         return $this->createdAt;
  197.     }
  198.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  199.     {
  200.         $this->createdAt $createdAt;
  201.         return $this;
  202.     }
  203.     public function getUpdatedAt(): ?\DateTimeInterface
  204.     {
  205.         return $this->updatedAt;
  206.     }
  207.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  208.     {
  209.         $this->updatedAt $updatedAt;
  210.         return $this;
  211.     }
  212.     public function __toString(): string
  213.     {
  214.         return $this->accountNumber ' - ' $this->accountName;
  215.     }
  216. }