<?php
namespace App\Entity;
use App\Entity\Traits\SerializableIdTrait;
use App\Repository\AnalysisServiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Table]
#[ORM\Index(name: 'service_id', columns: ['service_id'])]
#[ORM\Entity(repositoryClass: AnalysisServiceRepository::class)]
class AnalysisService
{
use TimestampableEntity;
use SerializableIdTrait;
#[ORM\Column(type: 'string', length: 255)]
private string $serviceId;
#[ORM\Column(type: 'text')]
private ?string $serviceName = null;
#[ORM\Column(type: 'json')]
private array $abilities;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: AnalysisServiceGroupService::class, orphanRemoval: true)]
private Collection $groupServices;
#[ORM\ManyToMany(targetEntity: Company::class, mappedBy: 'selectedAnalysisServices')]
private Collection $companies;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: AnalysisServicePrice::class, cascade: ['persist', 'remove'])]
private Collection $prices;
public function __construct()
{
$this->groupServices = new ArrayCollection();
$this->companies = new ArrayCollection();
$this->prices = new ArrayCollection();
$this->abilities = [];
}
public function getPrices(): Collection
{
return $this->prices;
}
public function getAbilities(): array
{
return $this->abilities;
}
public function setAbilities(array $abilities): self
{
$this->abilities = $abilities;
return $this;
}
public function getServiceId(): ?string
{
return $this->serviceId;
}
public function setServiceId(string $serviceId): self
{
$this->serviceId = $serviceId;
return $this;
}
public function getServiceName(): ?string
{
return $this->serviceName;
}
public function setServiceName(string $serviceName): self
{
$this->serviceName = $serviceName;
return $this;
}
public function getGroupServices(): Collection
{
return $this->groupServices;
}
public function addGroupService(AnalysisServiceGroupService $groupService): self
{
if (!$this->groupServices->contains($groupService)) {
$this->groupServices->add($groupService);
$groupService->setService($this);
}
return $this;
}
public function removeGroupService(AnalysisServiceGroupService $groupService): self
{
if ($this->groupServices->removeElement($groupService)) {
if ($groupService->getService() === $this) {
$groupService->setService(null);
}
}
return $this;
}
public function getCompanies(): Collection
{
return $this->companies;
}
public function addCompany(Company $company): self
{
if (!$this->companies->contains($company)) {
$this->companies->add($company);
$company->addSelectedAnalysisService($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->companies->contains($company)) {
$this->companies->removeElement($company);
$company->removeSelectedAnalysisService($this);
}
return $this;
}
}