This commit is contained in:
2024-12-26 17:45:58 +01:00
parent 9a2e4755e1
commit 4b798fd1f9
39 changed files with 1445 additions and 71 deletions

View File

@ -69,10 +69,24 @@ class Company
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'companys')]
private Collection $users;
/**
* @var Collection<int, Year>
*/
#[ORM\OneToMany(targetEntity: Year::class, mappedBy: 'company', orphanRemoval: true)]
private Collection $years;
/**
* @var Collection<int, Operation>
*/
#[ORM\OneToMany(targetEntity: Operation::class, mappedBy: 'company', orphanRemoval: true)]
private Collection $operations;
public function __construct()
{
$this->accountings = new ArrayCollection();
$this->users = new ArrayCollection();
$this->years = new ArrayCollection();
$this->operations = new ArrayCollection();
}
public function getId(): ?int
@ -280,4 +294,64 @@ class Company
return $this;
}
/**
* @return Collection<int, Year>
*/
public function getYears(): Collection
{
return $this->years;
}
public function addYear(Year $year): static
{
if (!$this->years->contains($year)) {
$this->years->add($year);
$year->setCompany($this);
}
return $this;
}
public function removeYear(Year $year): static
{
if ($this->years->removeElement($year)) {
// set the owning side to null (unless already changed)
if ($year->getCompany() === $this) {
$year->setCompany(null);
}
}
return $this;
}
/**
* @return Collection<int, Operation>
*/
public function getOperations(): Collection
{
return $this->operations;
}
public function addOperation(Operation $operation): static
{
if (!$this->operations->contains($operation)) {
$this->operations->add($operation);
$operation->setCompany($this);
}
return $this;
}
public function removeOperation(Operation $operation): static
{
if ($this->operations->removeElement($operation)) {
// set the owning side to null (unless already changed)
if ($operation->getCompany() === $this) {
$operation->setCompany(null);
}
}
return $this;
}
}