src/Entity/UserEleveCredit.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserEleveCreditRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=UserEleveCreditRepository::class)
  9.  */
  10. class UserEleveCredit
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="UserEleveCredits")
  20.      * @ORM\JoinColumn(nullable=false)
  21.      */
  22.     private $user;
  23.     /**
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $acquis;
  27.     /**
  28.      * @ORM\Column(type="integer")
  29.      */
  30.     private $restants;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=ShopCategorie::class, inversedBy="UserEleveCredits")
  33.      * @ORM\JoinColumn(nullable=false)
  34.      */
  35.     private $categorie;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=UserEleveCreditConsommation::class, mappedBy="credit")
  38.      */
  39.     private $userEleveCreditConsommations;
  40.     public function __construct()
  41.     {
  42.         $this->userEleveCreditConsommations = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getUser(): ?User
  49.     {
  50.         return $this->user;
  51.     }
  52.     public function setUser(?User $user): self
  53.     {
  54.         $this->user $user;
  55.         return $this;
  56.     }
  57.     public function getAcquis(): ?int
  58.     {
  59.         return $this->acquis;
  60.     }
  61.     public function setAcquis(int $acquis): self
  62.     {
  63.         $this->acquis $acquis;
  64.         return $this;
  65.     }
  66.     public function getRestants(): ?int
  67.     {
  68.         return $this->restants;
  69.     }
  70.     public function setRestants(int $restants): self
  71.     {
  72.         $this->restants $restants;
  73.         return $this;
  74.     }
  75.     public function addPoints(int $points): self
  76.     {
  77.         $this->restants += $points;
  78.         $this->acquis += $points;
  79.         return $this;
  80.     }
  81.     public function expendsPoints(int $points): self
  82.     {
  83.         $this->restants -= $points;
  84.         return $this;
  85.     }
  86.     public function redeemPoints(int $points): self
  87.     {
  88.         $this->restants += $points;
  89.         return $this;
  90.     }
  91.     public function getCategorie(): ?ShopCategorie
  92.     {
  93.         return $this->categorie;
  94.     }
  95.     public function setCategorie(?ShopCategorie $categorie): self
  96.     {
  97.         $this->categorie $categorie;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, UserEleveCreditConsommation>
  102.      */
  103.     public function getUserEleveCreditConsommations(): Collection
  104.     {
  105.         return $this->userEleveCreditConsommations;
  106.     }
  107.     public function addUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self
  108.     {
  109.         if (!$this->userEleveCreditConsommations->contains($userEleveCreditConsommation)) {
  110.             $this->userEleveCreditConsommations[] = $userEleveCreditConsommation;
  111.             $userEleveCreditConsommation->setCredit($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self
  116.     {
  117.         if ($this->userEleveCreditConsommations->removeElement($userEleveCreditConsommation)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($userEleveCreditConsommation->getCredit() === $this) {
  120.                 $userEleveCreditConsommation->setCredit(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125. }