src/Entity/Wallet.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WalletRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassWalletRepository::class)]
  8. class Wallet
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(nullabletrue)]
  15.     private ?int $value null;
  16.     #[ORM\OneToOne(inversedBy'wallet'cascade: ['persist''remove'])]
  17.     private ?User $user null;
  18.     #[ORM\OneToMany(targetEntityWithdraw::class, mappedBy'wallet')]
  19.     private Collection $withdraws;
  20.     public function __construct()
  21.     {
  22.        // $this->user = new ArrayCollection();
  23.        $this->withdraws = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getValue(): ?int
  30.     {
  31.         return $this->value;
  32.     }
  33.     public function setValue(?int $value): static
  34.     {
  35.         $this->value $value;
  36.         return $this;
  37.     }
  38.     function __toString()
  39.     {
  40.         return $this->value;
  41.     }
  42.     public function getUser(): ?User
  43.     {
  44.         return $this->user;
  45.     }
  46.     public function setUser(?User $user): static
  47.     {
  48.         $this->user $user;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection<int, Withdraw>
  53.      */
  54.     public function getWithdraws(): Collection
  55.     {
  56.         return $this->withdraws;
  57.     }
  58.     public function addWithdraw(Withdraw $withdraw): static
  59.     {
  60.         if (!$this->withdraws->contains($withdraw)) {
  61.             $this->withdraws->add($withdraw);
  62.             $withdraw->setWallet($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeWithdraw(Withdraw $withdraw): static
  67.     {
  68.         if ($this->withdraws->removeElement($withdraw)) {
  69.             // set the owning side to null (unless already changed)
  70.             if ($withdraw->getWallet() === $this) {
  71.                 $withdraw->setWallet(null);
  72.             }
  73.         }
  74.         return $this;
  75.     }
  76. }