<?phpnamespace App\Entity\Adherent;use App\Entity\BrandExceptionCategory;use App\Entity\Webfactory\WebfactoryCustomBrand;use App\Repository\Adherent\MagasinMarquesRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use App\Entity\Adherent\Brand;use Monolog\DateTimeImmutable;#[ORM\Entity(repositoryClass: MagasinMarquesRepository::class)]#[ORM\HasLifecycleCallbacks]class MagasinMarques implements \Stringable{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\ManyToOne(targetEntity: Magasin::class, inversedBy: 'magasinMarques')] #[ORM\JoinColumn(name: 'magasin', referencedColumnName: 'k_adherent')] private $magasin; #[ORM\Column(type: 'integer')] private $sort; #[ORM\Column(type: 'datetime_immutable')] private $created_at; #[ORM\Column(type: 'datetime_immutable')] private $updated_at; #[ORM\ManyToOne(targetEntity: Brand::class)] #[ORM\JoinColumn(nullable: false)] private $marque; #[ORM\OneToMany(targetEntity: BrandExceptionCategory::class, mappedBy: 'magasinMarque')] private $magasinMarquesException; #[ORM\OneToMany(mappedBy: 'magasinMarques', targetEntity: WebfactoryCustomBrand::class)] private Collection $webfactoryCustomBrands; #[ORM\Column] private ?bool $active = null; public function __construct() { $this->created_at = new \DateTimeImmutable("now"); $this->updated_at = new \DateTimeImmutable("now"); $this->webfactoryCustomBrands = new ArrayCollection(); $this->active = true; } #[ORM\PreUpdate] public function onPreUpdateEntity(): void { $this->updated_at = new DateTimeImmutable("now");// $this->updated_at = new DateTimeImmutable("now"); } public function getId(): ?int { return $this->id; } public function getMagasin(): ?Magasin { return $this->magasin; } public function setMagasin(?Magasin $magasin): self { $this->magasin = $magasin; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->created_at; } public function setCreatedAt(\DateTimeImmutable $created_at): self { $this->created_at = $created_at; return $this; } public function getUpdatedAt(): ?\DateTimeImmutable { return $this->updated_at; } public function setUpdatedAt(\DateTimeImmutable $updated_at): self { $this->updated_at = $updated_at; return $this; } /** * @return int */ public function getSort(): ?int { return $this->sort; } /** * @param mixed $sort */ public function setSort(int $sort): self { $this->sort = $sort; return $this; } public function getMarque(): ?Brand { return $this->marque; } public function setMarque(?Brand $marque): self { $this->marque = $marque; return $this; } public function getCategories() { $categories = []; foreach ($this->getMarque()->getCategory() as $category) { $categories[] = $category->getName(); } return $categories; } public function __toString(): string { return $this->magasin->getKAdherent() . " / " . $this->marque->getName(); } /** * @return mixed */ public function getMagasinMarquesException() { return $this->magasinMarquesException; } /** * @param mixed $magasinMarquesException */ public function setMagasinMarquesException($magasinMarquesException): void { $this->magasinMarquesException = $magasinMarquesException; } /** * @return Collection<int, WebfactoryCustomBrand> */ public function getWebfactoryCustomBrands(): Collection { return $this->webfactoryCustomBrands; } public function addWebfactoryCustomBrand(WebfactoryCustomBrand $webfactoryCustomBrand): static { if (!$this->webfactoryCustomBrands->contains($webfactoryCustomBrand)) { $this->webfactoryCustomBrands->add($webfactoryCustomBrand); $webfactoryCustomBrand->setMagasinMarques($this); } return $this; } public function removeWebfactoryCustomBrand(WebfactoryCustomBrand $webfactoryCustomBrand): static { if ($this->webfactoryCustomBrands->removeElement($webfactoryCustomBrand)) { // set the owning side to null (unless already changed) if ($webfactoryCustomBrand->getMagasinMarques() === $this) { $webfactoryCustomBrand->setMagasinMarques(null); } } return $this; } public function isActive(): ?bool { return $this->active; } public function setActive(bool $active): static { $this->active = $active; return $this; }}