<?phpnamespace App\Entity;use App\Repository\BrandRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: BrandRepository::class)]class Brand{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(length: 255)] private ?string $slug = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; #[ORM\Column(length: 255, nullable: true)] private ?string $logo = null; #[ORM\Column(length: 255, nullable: true)] private ?string $website = null; #[ORM\Column] private ?bool $isActive = true; #[ORM\Column] private ?\DateTimeImmutable $createdAt = null; #[ORM\Column] private ?\DateTimeImmutable $updatedAt = null; #[ORM\OneToMany(targetEntity: Product::class, mappedBy: 'brand')] private Collection $products; public function __construct() { $this->products = new ArrayCollection(); $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getSlug(): ?string { return $this->slug; } public function setSlug(string $slug): static { $this->slug = $slug; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getLogo(): ?string { return $this->logo; } public function setLogo(?string $logo): static { $this->logo = $logo; return $this; } public function getWebsite(): ?string { return $this->website; } public function setWebsite(?string $website): static { $this->website = $website; return $this; } public function isIsActive(): ?bool { return $this->isActive; } public function setIsActive(bool $isActive): static { $this->isActive = $isActive; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeImmutable { return $this->updatedAt; } public function setUpdatedAt(\DateTimeImmutable $updatedAt): static { $this->updatedAt = $updatedAt; return $this; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): static { if (!$this->products->contains($product)) { $this->products->add($product); $product->setBrand($this); } return $this; } public function removeProduct(Product $product): static { if ($this->products->removeElement($product)) { if ($product->getBrand() === $this) { $product->setBrand(null); } } return $this; } public function getActiveProductsCount(): int { return $this->products->filter(function(Product $product) { return $product->isIsActive(); })->count(); }}