<?php
namespace App\Entity;
use App\Repository\BankRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BankRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Bank
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=50)
*/
private $type; // bank, microfinance, financial_institution
/**
* @ORM\Column(type="text", nullable=true)
*/
private $address;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=20, options={"default": "active"})
*/
private $status = 'active'; // active, inactive
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $logo;
/**
* @ORM\OneToMany(targetEntity=Account::class, mappedBy="bank", cascade={"persist", "remove"})
*/
private $accounts;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->status = 'active';
$this->accounts = new ArrayCollection();
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue(): void
{
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): self
{
$this->logo = $logo;
return $this;
}
/**
* @return Collection|Account[]
*/
public function getAccounts(): Collection
{
return $this->accounts;
}
public function addAccount(Account $account): self
{
if (!$this->accounts->contains($account)) {
$this->accounts[] = $account;
$account->setBank($this);
}
return $this;
}
public function removeAccount(Account $account): self
{
if ($this->accounts->removeElement($account)) {
if ($account->getBank() === $this) {
$account->setBank(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function __toString(): string
{
return $this->name ?? '';
}
}