src/Entity/Adherent/MagasinMarques.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Adherent;
  3. use App\Entity\BrandExceptionCategory;
  4. use App\Entity\Webfactory\WebfactoryCustomBrand;
  5. use App\Repository\Adherent\MagasinMarquesRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use App\Entity\Adherent\Brand;
  10. use Monolog\DateTimeImmutable;
  11. #[ORM\Entity(repositoryClassMagasinMarquesRepository::class)]
  12. #[ORM\HasLifecycleCallbacks]
  13. class MagasinMarques implements \Stringable
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column(type'integer')]
  18.     private $id;
  19.     #[ORM\ManyToOne(targetEntityMagasin::class, inversedBy'magasinMarques')]
  20.     #[ORM\JoinColumn(name'magasin'referencedColumnName'k_adherent')]
  21.     private $magasin;
  22.     #[ORM\Column(type'integer')]
  23.     private $sort;
  24.     #[ORM\Column(type'datetime_immutable')]
  25.     private $created_at;
  26.     #[ORM\Column(type'datetime_immutable')]
  27.     private $updated_at;
  28.     #[ORM\ManyToOne(targetEntityBrand::class)]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private $marque;
  31.     #[ORM\OneToMany(targetEntityBrandExceptionCategory::class, mappedBy'magasinMarque')]
  32.     private $magasinMarquesException;
  33.     #[ORM\OneToMany(mappedBy'magasinMarques'targetEntityWebfactoryCustomBrand::class)]
  34.     private Collection $webfactoryCustomBrands;
  35.     #[ORM\Column]
  36.     private ?bool $active null;
  37.     public function __construct()
  38.     {
  39.         $this->created_at = new \DateTimeImmutable("now");
  40.         $this->updated_at = new \DateTimeImmutable("now");
  41.         $this->webfactoryCustomBrands = new ArrayCollection();
  42.         $this->active true;
  43.     }
  44.     #[ORM\PreUpdate]
  45.     public function onPreUpdateEntity(): void
  46.     {
  47.         $this->updated_at = new DateTimeImmutable("now");
  48. //        $this->updated_at = new DateTimeImmutable("now");
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getMagasin(): ?Magasin
  55.     {
  56.         return $this->magasin;
  57.     }
  58.     public function setMagasin(?Magasin $magasin): self
  59.     {
  60.         $this->magasin $magasin;
  61.         return $this;
  62.     }
  63.     public function getCreatedAt(): ?\DateTimeImmutable
  64.     {
  65.         return $this->created_at;
  66.     }
  67.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  68.     {
  69.         $this->created_at $created_at;
  70.         return $this;
  71.     }
  72.     public function getUpdatedAt(): ?\DateTimeImmutable
  73.     {
  74.         return $this->updated_at;
  75.     }
  76.     public function setUpdatedAt(\DateTimeImmutable $updated_at): self
  77.     {
  78.         $this->updated_at $updated_at;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return int
  83.      */
  84.     public function getSort(): ?int
  85.     {
  86.         return $this->sort;
  87.     }
  88.     /**
  89.      * @param mixed $sort
  90.      */
  91.     public function setSort(int $sort): self
  92.     {
  93.         $this->sort $sort;
  94.         return $this;
  95.     }
  96.     public function getMarque(): ?Brand
  97.     {
  98.         return $this->marque;
  99.     }
  100.     public function setMarque(?Brand $marque): self
  101.     {
  102.         $this->marque $marque;
  103.         return $this;
  104.     }
  105.     public function getCategories()
  106.     {
  107.         $categories = [];
  108.         foreach ($this->getMarque()->getCategory() as $category) {
  109.             $categories[] = $category->getName();
  110.         }
  111.         return $categories;
  112.     }
  113.     public function __toString(): string
  114.     {
  115.         return $this->magasin->getKAdherent() . " / " $this->marque->getName();
  116.     }
  117.     /**
  118.      * @return mixed
  119.      */
  120.     public function getMagasinMarquesException()
  121.     {
  122.         return $this->magasinMarquesException;
  123.     }
  124.     /**
  125.      * @param mixed $magasinMarquesException
  126.      */
  127.     public function setMagasinMarquesException($magasinMarquesException): void
  128.     {
  129.         $this->magasinMarquesException $magasinMarquesException;
  130.     }
  131.     /**
  132.      * @return Collection<int, WebfactoryCustomBrand>
  133.      */
  134.     public function getWebfactoryCustomBrands(): Collection
  135.     {
  136.         return $this->webfactoryCustomBrands;
  137.     }
  138.     public function addWebfactoryCustomBrand(WebfactoryCustomBrand $webfactoryCustomBrand): static
  139.     {
  140.         if (!$this->webfactoryCustomBrands->contains($webfactoryCustomBrand)) {
  141.             $this->webfactoryCustomBrands->add($webfactoryCustomBrand);
  142.             $webfactoryCustomBrand->setMagasinMarques($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeWebfactoryCustomBrand(WebfactoryCustomBrand $webfactoryCustomBrand): static
  147.     {
  148.         if ($this->webfactoryCustomBrands->removeElement($webfactoryCustomBrand)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($webfactoryCustomBrand->getMagasinMarques() === $this) {
  151.                 $webfactoryCustomBrand->setMagasinMarques(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     public function isActive(): ?bool
  157.     {
  158.         return $this->active;
  159.     }
  160.     public function setActive(bool $active): static
  161.     {
  162.         $this->active $active;
  163.         return $this;
  164.     }
  165. }