src/Entity/Bank.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BankRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=BankRepository::class)
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class Bank
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=50)
  25.      */
  26.     private $type// bank, microfinance, financial_institution
  27.     /**
  28.      * @ORM\Column(type="text", nullable=true)
  29.      */
  30.     private $address;
  31.     /**
  32.      * @ORM\Column(type="string", length=50, nullable=true)
  33.      */
  34.     private $phone;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      */
  38.     private $email;
  39.     /**
  40.      * @ORM\Column(type="string", length=20, options={"default": "active"})
  41.      */
  42.     private $status 'active'// active, inactive
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $logo;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=Account::class, mappedBy="bank", cascade={"persist", "remove"})
  49.      */
  50.     private $accounts;
  51.     /**
  52.      * @ORM\Column(type="datetime")
  53.      */
  54.     private $createdAt;
  55.     /**
  56.      * @ORM\Column(type="datetime", nullable=true)
  57.      */
  58.     private $updatedAt;
  59.     public function __construct()
  60.     {
  61.         $this->createdAt = new \DateTime();
  62.         $this->status 'active';
  63.         $this->accounts = new ArrayCollection();
  64.     }
  65.     /**
  66.      * @ORM\PreUpdate
  67.      */
  68.     public function setUpdatedAtValue(): void
  69.     {
  70.         $this->updatedAt = new \DateTime();
  71.     }
  72.     public function getId(): ?int
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getName(): ?string
  77.     {
  78.         return $this->name;
  79.     }
  80.     public function setName(string $name): self
  81.     {
  82.         $this->name $name;
  83.         return $this;
  84.     }
  85.     public function getType(): ?string
  86.     {
  87.         return $this->type;
  88.     }
  89.     public function setType(string $type): self
  90.     {
  91.         $this->type $type;
  92.         return $this;
  93.     }
  94.     public function getAddress(): ?string
  95.     {
  96.         return $this->address;
  97.     }
  98.     public function setAddress(?string $address): self
  99.     {
  100.         $this->address $address;
  101.         return $this;
  102.     }
  103.     public function getPhone(): ?string
  104.     {
  105.         return $this->phone;
  106.     }
  107.     public function setPhone(?string $phone): self
  108.     {
  109.         $this->phone $phone;
  110.         return $this;
  111.     }
  112.     public function getEmail(): ?string
  113.     {
  114.         return $this->email;
  115.     }
  116.     public function setEmail(?string $email): self
  117.     {
  118.         $this->email $email;
  119.         return $this;
  120.     }
  121.     public function getStatus(): ?string
  122.     {
  123.         return $this->status;
  124.     }
  125.     public function setStatus(string $status): self
  126.     {
  127.         $this->status $status;
  128.         return $this;
  129.     }
  130.     public function getLogo(): ?string
  131.     {
  132.         return $this->logo;
  133.     }
  134.     public function setLogo(?string $logo): self
  135.     {
  136.         $this->logo $logo;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection|Account[]
  141.      */
  142.     public function getAccounts(): Collection
  143.     {
  144.         return $this->accounts;
  145.     }
  146.     public function addAccount(Account $account): self
  147.     {
  148.         if (!$this->accounts->contains($account)) {
  149.             $this->accounts[] = $account;
  150.             $account->setBank($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeAccount(Account $account): self
  155.     {
  156.         if ($this->accounts->removeElement($account)) {
  157.             if ($account->getBank() === $this) {
  158.                 $account->setBank(null);
  159.             }
  160.         }
  161.         return $this;
  162.     }
  163.     public function getCreatedAt(): ?\DateTimeInterface
  164.     {
  165.         return $this->createdAt;
  166.     }
  167.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  168.     {
  169.         $this->createdAt $createdAt;
  170.         return $this;
  171.     }
  172.     public function getUpdatedAt(): ?\DateTimeInterface
  173.     {
  174.         return $this->updatedAt;
  175.     }
  176.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  177.     {
  178.         $this->updatedAt $updatedAt;
  179.         return $this;
  180.     }
  181.     public function __toString(): string
  182.     {
  183.         return $this->name ?? '';
  184.     }
  185. }