src/Entity/CategoryResidence.php line 14

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryResidenceRepository;
  4. use App\Traits\TimeStampTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. #[ORM\Entity(repositoryClassCategoryResidenceRepository::class)]
  10. #[ORM\HasLifecycleCallbacks]
  11. class CategoryResidence
  12. {
  13.     use TimeStampTrait;
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length100)]
  19.     private ?string $libelle null;
  20.     #[ORM\Column(length100)]
  21.     private ?string $code null;
  22.     #[ORM\Column(nullabletrue)]
  23.     private ?bool $status null;
  24.     #[ORM\ManyToOne(inversedBy'categoryResidences')]
  25.     private ?User $createdBy null;
  26.     #[ORM\ManyToMany(targetEntityResidence::class, mappedBy'category')]
  27.     private Collection $residences;
  28.     #[ORM\ManyToOne(inversedBy'categoryResidences')]
  29.     private ?Entreprise $marchand null;
  30.     public function __construct()
  31.     {
  32.         $this->residences = new ArrayCollection();
  33.     }
  34.     public function __toString()
  35.     {
  36.         return $this->libelle;
  37.     }
  38.     /**
  39.      * @return int|null
  40.      */
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     /**
  46.      * @param int|null $id
  47.      */
  48.     public function setId(?int $id): void
  49.     {
  50.         $this->id $id;
  51.     }
  52.     /**
  53.      * @return string|null
  54.      */
  55.     public function getLibelle(): ?string
  56.     {
  57.         return $this->libelle;
  58.     }
  59.     /**
  60.      * @param string|null $libelle
  61.      */
  62.     public function setLibelle(?string $libelle): void
  63.     {
  64.         $this->libelle $libelle;
  65.     }
  66.     /**
  67.      * @return string|null
  68.      */
  69.     public function getCode(): ?string
  70.     {
  71.         return $this->code;
  72.     }
  73.     /**
  74.      * @param string|null $code
  75.      */
  76.     public function setCode(?string $code): void
  77.     {
  78.         $this->code $code;
  79.     }
  80.     /**
  81.      * @return bool|null
  82.      */
  83.     public function getStatus(): ?bool
  84.     {
  85.         return $this->status;
  86.     }
  87.     /**
  88.      * @param bool|null $status
  89.      */
  90.     public function setStatus(?bool $status): void
  91.     {
  92.         $this->status $status;
  93.     }
  94.     /**
  95.      * @return User|null
  96.      */
  97.     public function getCreatedBy(): ?User
  98.     {
  99.         return $this->createdBy;
  100.     }
  101.     /**
  102.      * @param User|null $createdBy
  103.      */
  104.     public function setCreatedBy(?User $createdBy): void
  105.     {
  106.         $this->createdBy $createdBy;
  107.     }
  108.     /**
  109.      * @return Collection<int, Residence>
  110.      */
  111.     public function getResidences(): Collection
  112.     {
  113.         return $this->residences;
  114.     }
  115.     public function addResidence(Residence $residence): static
  116.     {
  117.         if (!$this->residences->contains($residence)) {
  118.             $this->residences->add($residence);
  119.             $residence->addCategory($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeResidence(Residence $residence): static
  124.     {
  125.         if ($this->residences->removeElement($residence)) {
  126.             $residence->removeCategory($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function getMarchand(): ?Entreprise
  131.     {
  132.         return $this->marchand;
  133.     }
  134.     public function setMarchand(?Entreprise $marchand): static
  135.     {
  136.         $this->marchand $marchand;
  137.         return $this;
  138.     }
  139. }