<?php
namespace App\Entity;
use App\Entity\Trait\CreatedAtTrait;
use App\Repository\CategoriesEntreprisesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoriesEntreprisesRepository::class)]
class CategoriesEntreprises
{
use CreatedAtTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
/* #[ORM\Column(type: Types::TEXT)]
private ?string $description = null; */
#[ORM\Column(length: 255)]
private ?string $description = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'categoriesentreprises', targetEntity: Entreprises::class)]
private Collection $entreprises;
public function __construct()
{
$this->entreprises = new ArrayCollection();
$this->created_at = 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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): static
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Entreprises>
*/
public function getEntreprises(): Collection
{
return $this->entreprises;
}
public function addEntreprise(Entreprises $entreprise): static
{
if (!$this->entreprises->contains($entreprise)) {
$this->entreprises->add($entreprise);
$entreprise->setCategoriesentreprises($this);
}
return $this;
}
public function removeEntreprise(Entreprises $entreprise): static
{
if ($this->entreprises->removeElement($entreprise)) {
// set the owning side to null (unless already changed)
if ($entreprise->getCategoriesentreprises() === $this) {
$entreprise->setCategoriesentreprises(null);
}
}
return $this;
}
}