src/Entity/Category.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  9. class Category
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $nom null;
  17.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  18.     private ?string $tax null;
  19.     #[ORM\OneToMany(mappedBy'category'targetEntityProduit::class)]
  20.     private Collection $produits;
  21.     public function __construct()
  22.     {
  23.         $this->produits = new ArrayCollection();
  24.     }
  25.     public function getId(): ?int
  26.     {
  27.         return $this->id;
  28.     }
  29.     public function getNom(): ?string
  30.     {
  31.         return $this->nom;
  32.     }
  33.     public function setNom(string $nom): self
  34.     {
  35.         $this->nom $nom;
  36.         return $this;
  37.     }
  38.     public function getTax(): ?string
  39.     {
  40.         return $this->tax;
  41.     }
  42.     public function setTax(?string $tax): self
  43.     {
  44.         $this->tax $tax;
  45.         return $this;
  46.     }
  47.     /**
  48.      * @return Collection<int, Produit>
  49.      */
  50.     public function getProduits(): Collection
  51.     {
  52.         return $this->produits;
  53.     }
  54.     public function addProduit(Produit $produit): self
  55.     {
  56.         if (!$this->produits->contains($produit)) {
  57.             $this->produits->add($produit);
  58.             $produit->setCategory($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeProduit(Produit $produit): self
  63.     {
  64.         if ($this->produits->removeElement($produit)) {
  65.             // set the owning side to null (unless already changed)
  66.             if ($produit->getCategory() === $this) {
  67.                 $produit->setCategory(null);
  68.             }
  69.         }
  70.         return $this;
  71.     }
  72.     public function __toString(): string{
  73.         return $this->nom;
  74.     }
  75. }