<?phpnamespace App\Entity;use App\Repository\UserEleveCreditRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=UserEleveCreditRepository::class) */class UserEleveCredit{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="UserEleveCredits") * @ORM\JoinColumn(nullable=false) */ private $user; /** * @ORM\Column(type="integer") */ private $acquis; /** * @ORM\Column(type="integer") */ private $restants; /** * @ORM\ManyToOne(targetEntity=ShopCategorie::class, inversedBy="UserEleveCredits") * @ORM\JoinColumn(nullable=false) */ private $categorie; /** * @ORM\OneToMany(targetEntity=UserEleveCreditConsommation::class, mappedBy="credit") */ private $userEleveCreditConsommations; public function __construct() { $this->userEleveCreditConsommations = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getAcquis(): ?int { return $this->acquis; } public function setAcquis(int $acquis): self { $this->acquis = $acquis; return $this; } public function getRestants(): ?int { return $this->restants; } public function setRestants(int $restants): self { $this->restants = $restants; return $this; } public function addPoints(int $points): self { $this->restants += $points; $this->acquis += $points; return $this; } public function expendsPoints(int $points): self { $this->restants -= $points; return $this; } public function redeemPoints(int $points): self { $this->restants += $points; return $this; } public function getCategorie(): ?ShopCategorie { return $this->categorie; } public function setCategorie(?ShopCategorie $categorie): self { $this->categorie = $categorie; return $this; } /** * @return Collection<int, UserEleveCreditConsommation> */ public function getUserEleveCreditConsommations(): Collection { return $this->userEleveCreditConsommations; } public function addUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self { if (!$this->userEleveCreditConsommations->contains($userEleveCreditConsommation)) { $this->userEleveCreditConsommations[] = $userEleveCreditConsommation; $userEleveCreditConsommation->setCredit($this); } return $this; } public function removeUserEleveCreditConsommation(UserEleveCreditConsommation $userEleveCreditConsommation): self { if ($this->userEleveCreditConsommations->removeElement($userEleveCreditConsommation)) { // set the owning side to null (unless already changed) if ($userEleveCreditConsommation->getCredit() === $this) { $userEleveCreditConsommation->setCredit(null); } } return $this; }}