src/Entity/Product.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\TranslationModel;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Entity(repositoryClass'App\Repository\ProductRepository')]
  9. #[ORM\Table(name'product')]
  10. #[ORM\InheritanceType('JOINED')]
  11. #[ORM\DiscriminatorColumn(name'discr'type'string')]
  12. #[ORM\DiscriminatorMap(['product' => Product::class, 'service' => Service::class, 'marchandise' => Marchandise::class])]
  13. class Product extends TranslationModel
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue(strategy'AUTO')]
  17.     #[ORM\Column(type'integer'uniquetrue)]
  18.     #[Groups(['company''category'])]
  19.     protected $id;
  20.     #[ORM\ManyToOne(targetEntityUser::class)]
  21.     #[ORM\JoinColumn(name'owner'referencedColumnName'id')]
  22.     #[Groups(['company''category'])]
  23.     private $owner;
  24.     #[ORM\Column(name'name'type'string'length255)]
  25.     #[Groups(['company''category'])]
  26.     protected $name;
  27.     #[ORM\Column(name'latitude'type'decimal'nullabletrue)]
  28.     #[Groups(['company''category'])]
  29.     protected $latitude;
  30.     #[ORM\Column(name'longitude'type'decimal'nullabletrue)]
  31.     #[Groups(['company''category'])]
  32.     protected $longitude;
  33.     #[ORM\Column(name'description'type'text'nullabletrue)]
  34.     #[Groups(['company''category'])]
  35.     protected $description;
  36.     #[ORM\Column(name'niveau'type'string'length255nullabletrue)]
  37.     #[Groups(['company''category'])]
  38.     protected $niveau;
  39.     #[ORM\Column(name'origin'type'string'length255nullabletrue)]
  40.     #[Groups(['company''category'])]
  41.     protected $origin;
  42.     #[ORM\Column(name'slug'type'string'length255)]
  43.     #[Groups(['company''category'])]
  44.     protected $slug;
  45.     #[ORM\Column(name'certification'type'string'length255)]
  46.     #[Groups(['company''category'])]
  47.     protected $certification;
  48.     #[ORM\Column(name'price'type'float'nullabletrue)]
  49.     #[Groups(['company''category'])]
  50.     protected $price;
  51.     #[ORM\Column(name'currency'type'string'length255nullabletrue)]
  52.     #[Groups(['company''category'])]
  53.     protected $currency;
  54.     #[ORM\Column(name'wantevaluation'type'boolean')]
  55.     #[Groups(['company''category'])]
  56.     protected $wantevaluation;
  57.     #[ORM\Column(name'gaearecommanded'type'boolean')]
  58.     #[Groups(['company''category'])]
  59.     protected $gaearecommanded;
  60.     #[ORM\Column(name'creation_date'type'date')]
  61.     #[Groups(['company''category'])]
  62.     protected $creationdate;
  63.     #[ORM\Column(name'updated_date'type'date'nullabletrue)]
  64.     #[Groups(['company''category'])]
  65.     protected $updateddate;
  66.     #[ORM\Column(name'image'type'string'length255nullabletrue)]
  67.     #[Groups(['company''category'])]
  68.     protected $image;
  69.     #[ORM\Column(name'type'type'string'length255)]
  70.     #[Groups(['company''category'])]
  71.     protected $type;
  72.     #[ORM\ManyToOne(targetEntityCompany::class, inversedBy'products')]
  73.     #[ORM\JoinColumn(name'company_id'referencedColumnName'id'nullablefalse)]
  74.     #[Groups(['category'])]
  75.     protected $company;
  76.     #[ORM\ManyToOne(targetEntityCategory::class)]
  77.     #[ORM\JoinColumn(name'category_id'referencedColumnName'id')]
  78.     #[Groups(['company''category'])]
  79.     protected $category;
  80.     #[ORM\ManyToMany(targetEntity'App\Entity\Subcategory'inversedBy'products')]
  81.     #[ORM\JoinTable(name'product_subcategory')]
  82.     #[Groups(['company''category'])]
  83.     protected Collection $subcategories;
  84.     #[ORM\OneToMany(targetEntity'App\Entity\ProductFav'mappedBy'product'orphanRemovaltruecascade: ['remove'])]
  85.     protected Collection $productFavProducts;
  86.     public function __construct()
  87.     {
  88.         parent::__construct();
  89.         $this->creationdate = new \DateTime();
  90.         $this->subcategories = new ArrayCollection();
  91.         $this->productFavProducts = new ArrayCollection();
  92.     }
  93.     public function getId(): ?int
  94.     {
  95.         return $this->id;
  96.     }
  97.     public function getName(): ?string
  98.     {
  99.         return $this->name;
  100.     }
  101.     public function setName(string $name): self
  102.     {
  103.         $this->name $name;
  104.         return $this;
  105.     }
  106.     public function getOwner()
  107.     {
  108.         return $this->owner;
  109.     }
  110.     public function setOwner($owner): self
  111.     {
  112.         $this->owner $owner;
  113.         return $this;
  114.     }
  115.     public function getCompany(): ?Company
  116.     {
  117.         return $this->company;
  118.     }
  119.     public function setCompany(?Company $company): self
  120.     {
  121.         $this->company $company;
  122.         return $this;
  123.     }
  124.     public function getCategory(): ?Category
  125.     {
  126.         return $this->category;
  127.     }
  128.     public function setCategory(?Category $category): self
  129.     {
  130.         $this->category $category;
  131.         return $this;
  132.     }
  133.     public function getSubcategories(): Collection
  134.     {
  135.         return $this->subcategories;
  136.     }
  137.     public function addSubcategory($subcategory): self
  138.     {
  139.         if (!$this->subcategories->contains($subcategory)) {
  140.             $this->subcategories->add($subcategory);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeSubcategory($subcategory): self
  145.     {
  146.         $this->subcategories->removeElement($subcategory);
  147.         return $this;
  148.     }
  149.     public function getProductFavProducts(): Collection
  150.     {
  151.         return $this->productFavProducts;
  152.     }
  153.     public function addProductFavProduct($productFavProduct): self
  154.     {
  155.         if (!$this->productFavProducts->contains($productFavProduct)) {
  156.             $this->productFavProducts->add($productFavProduct);
  157.             $productFavProduct->setProduct($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeProductFavProduct($productFavProduct): self
  162.     {
  163.         if ($this->productFavProducts->removeElement($productFavProduct)) {
  164.             if ($productFavProduct->getProduct() === $this) {
  165.                 $productFavProduct->setProduct(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getLatitude(): ?float
  171.     {
  172.         return $this->latitude;
  173.     }
  174.     public function setLatitude(?float $latitude): self
  175.     {
  176.         $this->latitude $latitude;
  177.         return $this;
  178.     }
  179.     public function getLongitude(): ?float
  180.     {
  181.         return $this->longitude;
  182.     }
  183.     public function setLongitude(?float $longitude): self
  184.     {
  185.         $this->longitude $longitude;
  186.         return $this;
  187.     }
  188.     public function getDescription(): ?string
  189.     {
  190.         return $this->description;
  191.     }
  192.     public function setDescription(?string $description): self
  193.     {
  194.         $this->description $description;
  195.         return $this;
  196.     }
  197.     public function getNiveau(): ?string
  198.     {
  199.         return $this->niveau;
  200.     }
  201.     public function setNiveau(?string $niveau): self
  202.     {
  203.         $this->niveau $niveau;
  204.         return $this;
  205.     }
  206.     
  207.     public function getOrigin(): ?string
  208.     {
  209.         return $this->origin;
  210.     }
  211.     public function setOrigin(?string $origin): self
  212.     {
  213.         $this->origin $origin;
  214.         return $this;
  215.     }
  216.     
  217.     public function getSlug(): ?string
  218.     {
  219.         return $this->slug;
  220.     }
  221.     public function setSlug(?string $slug): self
  222.     {
  223.         $this->slug $slug;
  224.         return $this;
  225.     }
  226.     
  227.     public function getCertification(): ?string
  228.     {
  229.         return $this->certification;
  230.     }
  231.     public function setCertification(?string $certification): self
  232.     {
  233.         $this->certification $certification;
  234.         return $this;
  235.     }
  236.     
  237.     public function getPrice(): ?float
  238.     {
  239.         return $this->price;
  240.     }
  241.     public function setPrice(?float $price): self
  242.     {
  243.         $this->price $price;
  244.         return $this;
  245.     }
  246.     
  247.     public function getCurrency(): ?string
  248.     {
  249.         return $this->currency;
  250.     }
  251.     public function setCurrency(?string $currency): self
  252.     {
  253.         $this->currency $currency;
  254.         return $this;
  255.     }
  256.     
  257.     public function getWantevaluation(): ?bool
  258.     {
  259.         return $this->wantevaluation;
  260.     }
  261.     public function setWantevaluation(?bool $wantevaluation): self
  262.     {
  263.         $this->wantevaluation $wantevaluation;
  264.         return $this;
  265.     }
  266.     
  267.     public function getGaearecommanded(): ?bool
  268.     {
  269.         return $this->gaearecommanded;
  270.     }
  271.     public function setGaearecommanded(?bool $gaearecommanded): self
  272.     {
  273.         $this->gaearecommanded $gaearecommanded;
  274.         return $this;
  275.     }
  276.     
  277.     public function getCreationdate(): ?\DateTimeInterface
  278.     {
  279.         return $this->creationdate;
  280.     }
  281.     public function setCreationdate(?\DateTimeInterface $creationdate): self
  282.     {
  283.         $this->creationdate $creationdate;
  284.         return $this;
  285.     }
  286.     
  287.     public function getUpdateddate(): ?\DateTimeInterface
  288.     {
  289.         return $this->updateddate;
  290.     }
  291.     public function setUpdateddate(?\DateTimeInterface $updateddate): self
  292.     {
  293.         $this->updateddate $updateddate;
  294.         return $this;
  295.     }
  296.     
  297.     public function getImage(): ?string
  298.     {
  299.         return $this->image;
  300.     }
  301.     public function setImage(?string $image): self
  302.     {
  303.         $this->image $image;
  304.         return $this;
  305.     }
  306.     
  307.     public function getType(): ?string
  308.     {
  309.         return $this->type;
  310.     }
  311.     public function setType(?string $type): self
  312.     {
  313.         $this->type $type;
  314.         return $this;
  315.     }
  316. }