<?phpnamespace App\Entity\User;use App\Entity\BaseEntity;use App\Entity\User;use App\Repository\User\WalletRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=WalletRepository::class) * @ORM\HasLifecycleCallbacks() */class Wallet extends BaseEntity{ /** * @ORM\Column(type="float") */ private $balance; /** * @ORM\Column(type="float") * Montant in pending withdraw */ private $pending; /** * @ORM\Column(type="float") */ private $incoming; /** * @ORM\OneToOne(targetEntity=User::class, inversedBy="wallet", cascade={"persist", "remove"}) * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\OneToMany(targetEntity=Transaction::class, mappedBy="wallet") */ private $transactions; public function __construct() { parent::__construct(); $this->balance = 0; $this->pending = 0; $this->incoming = 0; $this->transactions = new ArrayCollection(); } public function getBalance(): ?float { return $this->balance; } public function setBalance(float $balance): self { $this->balance = $balance; return $this; } public function getPending(): ?float { return $this->pending; } public function setPending(float $pending): self { $this->pending = $pending; return $this; } public function getIncoming(): ?float { return $this->incoming; } public function setIncoming(float $incoming): self { $this->incoming = $incoming; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(User $user): self { $this->user = $user; return $this; } /** * @return Collection|Transaction[] */ public function getTransactions(): Collection { return $this->transactions; } public function addTransaction(Transaction $transaction): self { if (!$this->transactions->contains($transaction)) { $this->transactions[] = $transaction; $transaction->setWallet($this); } return $this; } public function removeTransaction(Transaction $transaction): self { if ($this->transactions->removeElement($transaction)) { // set the owning side to null (unless already changed) if ($transaction->getWallet() === $this) { $transaction->setWallet(null); } } return $this; }}