<?php
namespace App\Entity;
use App\Repository\WalletRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: WalletRepository::class)]
class Wallet
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?int $value = null;
#[ORM\OneToOne(inversedBy: 'wallet', cascade: ['persist', 'remove'])]
private ?User $user = null;
#[ORM\OneToMany(targetEntity: Withdraw::class, mappedBy: 'wallet')]
private Collection $withdraws;
public function __construct()
{
// $this->user = new ArrayCollection();
$this->withdraws = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getValue(): ?int
{
return $this->value;
}
public function setValue(?int $value): static
{
$this->value = $value;
return $this;
}
function __toString()
{
return $this->value;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
/**
* @return Collection<int, Withdraw>
*/
public function getWithdraws(): Collection
{
return $this->withdraws;
}
public function addWithdraw(Withdraw $withdraw): static
{
if (!$this->withdraws->contains($withdraw)) {
$this->withdraws->add($withdraw);
$withdraw->setWallet($this);
}
return $this;
}
public function removeWithdraw(Withdraw $withdraw): static
{
if ($this->withdraws->removeElement($withdraw)) {
// set the owning side to null (unless already changed)
if ($withdraw->getWallet() === $this) {
$withdraw->setWallet(null);
}
}
return $this;
}
}