src/Entity/AnalysisService.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\SerializableIdTrait;
  4. use App\Repository\AnalysisServiceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Table]
  10. #[ORM\Index(name: 'service_id', columns: ['service_id'])]
  11. #[ORM\Entity(repositoryClass: AnalysisServiceRepository::class)]
  12. class AnalysisService
  13. {
  14. use TimestampableEntity;
  15. use SerializableIdTrait;
  16. #[ORM\Column(type: 'string', length: 255)]
  17. private string $serviceId;
  18. #[ORM\Column(type: 'text')]
  19. private ?string $serviceName = null;
  20. #[ORM\Column(type: 'json')]
  21. private array $abilities;
  22. #[ORM\OneToMany(mappedBy: 'service', targetEntity: AnalysisServiceGroupService::class, orphanRemoval: true)]
  23. private Collection $groupServices;
  24. #[ORM\ManyToMany(targetEntity: Company::class, mappedBy: 'selectedAnalysisServices')]
  25. private Collection $companies;
  26. #[ORM\OneToMany(mappedBy: 'service', targetEntity: AnalysisServicePrice::class, cascade: ['persist', 'remove'])]
  27. private Collection $prices;
  28. public function __construct()
  29. {
  30. $this->groupServices = new ArrayCollection();
  31. $this->companies = new ArrayCollection();
  32. $this->prices = new ArrayCollection();
  33. $this->abilities = [];
  34. }
  35. public function getPrices(): Collection
  36. {
  37. return $this->prices;
  38. }
  39. public function getAbilities(): array
  40. {
  41. return $this->abilities;
  42. }
  43. public function setAbilities(array $abilities): self
  44. {
  45. $this->abilities = $abilities;
  46. return $this;
  47. }
  48. public function getServiceId(): ?string
  49. {
  50. return $this->serviceId;
  51. }
  52. public function setServiceId(string $serviceId): self
  53. {
  54. $this->serviceId = $serviceId;
  55. return $this;
  56. }
  57. public function getServiceName(): ?string
  58. {
  59. return $this->serviceName;
  60. }
  61. public function setServiceName(string $serviceName): self
  62. {
  63. $this->serviceName = $serviceName;
  64. return $this;
  65. }
  66. public function getGroupServices(): Collection
  67. {
  68. return $this->groupServices;
  69. }
  70. public function addGroupService(AnalysisServiceGroupService $groupService): self
  71. {
  72. if (!$this->groupServices->contains($groupService)) {
  73. $this->groupServices->add($groupService);
  74. $groupService->setService($this);
  75. }
  76. return $this;
  77. }
  78. public function removeGroupService(AnalysisServiceGroupService $groupService): self
  79. {
  80. if ($this->groupServices->removeElement($groupService)) {
  81. if ($groupService->getService() === $this) {
  82. $groupService->setService(null);
  83. }
  84. }
  85. return $this;
  86. }
  87. public function getCompanies(): Collection
  88. {
  89. return $this->companies;
  90. }
  91. public function addCompany(Company $company): self
  92. {
  93. if (!$this->companies->contains($company)) {
  94. $this->companies->add($company);
  95. $company->addSelectedAnalysisService($this);
  96. }
  97. return $this;
  98. }
  99. public function removeCompany(Company $company): self
  100. {
  101. if ($this->companies->contains($company)) {
  102. $this->companies->removeElement($company);
  103. $company->removeSelectedAnalysisService($this);
  104. }
  105. return $this;
  106. }
  107. }