src/Entity/Service.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ServiceRepository;
  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. #[ORM\Entity(repositoryClassServiceRepository::class)]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Service
  11. {
  12.     use TimeStampTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length100)]
  18.     private ?string $code null;
  19.     #[ORM\Column(length50)]
  20.     private ?string $name null;
  21.     #[ORM\Column]
  22.     private ?bool $status null;
  23.     #[ORM\OneToMany(mappedBy'service'targetEntityIncident::class)]
  24.     private Collection $incidents;
  25.     #[ORM\OneToMany(mappedBy'service'targetEntityPrestataire::class)]
  26.     private Collection $prestataires;
  27.     #[ORM\ManyToOne(inversedBy'services')]
  28.     private ?Entreprise $marchand null;
  29.     #[ORM\ManyToOne(inversedBy'services')]
  30.     private ?User $createdBy null;
  31.     public function __construct()
  32.     {
  33.         $this->incidents = new ArrayCollection();
  34.         $this->prestataires = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getCode(): ?string
  41.     {
  42.         return $this->code;
  43.     }
  44.     public function setCode(string $code): static
  45.     {
  46.         $this->code $code;
  47.         return $this;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): static
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function isStatus(): ?bool
  59.     {
  60.         return $this->status;
  61.     }
  62.     public function setStatus(bool $status): static
  63.     {
  64.         $this->status $status;
  65.         return $this;
  66.     }
  67.     /**
  68.      * @return Collection<int, Incident>
  69.      */
  70.     public function getIncidents(): Collection
  71.     {
  72.         return $this->incidents;
  73.     }
  74.     public function addIncident(Incident $incident): static
  75.     {
  76.         if (!$this->incidents->contains($incident)) {
  77.             $this->incidents->add($incident);
  78.             $incident->setService($this);
  79.         }
  80.         return $this;
  81.     }
  82.     public function removeIncident(Incident $incident): static
  83.     {
  84.         if ($this->incidents->removeElement($incident)) {
  85.             // set the owning side to null (unless already changed)
  86.             if ($incident->getService() === $this) {
  87.                 $incident->setService(null);
  88.             }
  89.         }
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection<int, Prestataire>
  94.      */
  95.     public function getPrestataires(): Collection
  96.     {
  97.         return $this->prestataires;
  98.     }
  99.     public function addPrestataire(Prestataire $prestataire): static
  100.     {
  101.         if (!$this->prestataires->contains($prestataire)) {
  102.             $this->prestataires->add($prestataire);
  103.             $prestataire->setService($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removePrestataire(Prestataire $prestataire): static
  108.     {
  109.         if ($this->prestataires->removeElement($prestataire)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($prestataire->getService() === $this) {
  112.                 $prestataire->setService(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     public function __toString(): string
  118.     {
  119.         return $this->name;
  120.     }
  121.     public function getMarchand(): ?Entreprise
  122.     {
  123.         return $this->marchand;
  124.     }
  125.     public function setMarchand(?Entreprise $marchand): static
  126.     {
  127.         $this->marchand $marchand;
  128.         return $this;
  129.     }
  130.     public function getCreatedBy(): ?User
  131.     {
  132.         return $this->createdBy;
  133.     }
  134.     public function setCreatedBy(?User $createdBy): static
  135.     {
  136.         $this->createdBy $createdBy;
  137.         return $this;
  138.     }
  139. }