← Back
Editing: Organization.php
<?php namespace App\Entity; use App\Entity\Traits\ActivableTrait; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Annotation\Groups; #[ORM\Table(name: 'organization')] #[ORM\Entity(repositoryClass: 'App\Repository\OrganizationRepository')] class Organization { use ActivableTrait; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] #[Groups(['show_user', 'show_organization'])] protected ?int $id = null; #[ORM\Column(type: 'string', length: 180)] #[Groups(['show_user', 'show_organization'])] private ?string $name = null; #[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])] private ?\DateTimeInterface $updatedAt = null; #[ORM\ManyToMany(targetEntity: Solution::class, inversedBy: 'organizations')] private ?Collection $solutions = null; #[ORM\Column(name: 'logo', type: 'string', length: 255, nullable: true)] #[Groups(['show_user', 'show_organization'])] private ?string $logo = null; #[ORM\OneToMany(mappedBy: 'organization', targetEntity: Agency::class)] private Collection $agencies; #[ORM\OneToMany(mappedBy: 'organization', targetEntity: User::class)] private Collection $users; public function __construct() { $this->agencies = new ArrayCollection(); $this->users = new ArrayCollection(); $this->updatedAt = new \DateTime(); $this->solutions = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function setId($id): self { $this->id = $id; return $this; } public function __toString() { return $this->name; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(\DateTimeInterface $updatedAt): self { $this->updatedAt = $updatedAt; return $this; } public function getSolutions(): ?Collection { return $this->solutions; } /** * @return $this */ public function addSolution(Solution $solution): self { if (!$this->solutions->contains($solution)) { $this->solutions[] = $solution; } return $this; } /** * @return $this */ public function removeSolution(Solution $solution): self { if ($this->solutions->contains($solution)) { $this->solutions->removeElement($solution); } return $this; } public function hasSolution(Solution $solution): bool { foreach ($this->getSolutions() as $item) { if ($solution->getId() === $item->getId()) { return true; } } return false; } public function getLogo(): ?string { return $this->logo; } public function setLogo(?string $logo): self { $this->logo = $logo; return $this; } /** * @return Collection<int, Agency> */ public function getAgencies(): Collection { return $this->agencies; } public function addAgency(Agency $agency): self { if (!$this->agencies->contains($agency)) { $this->agencies[] = $agency; $agency->setOrganization($this); } return $this; } public function removeAgency(Agency $agency): self { if ($this->agencies->removeElement($agency)) { // set the owning side to null (unless already changed) if ($agency->getOrganization() === $this) { $agency->setOrganization(null); } } return $this; } public function getUsers(): ?Collection { return $this->users; } public function addUser(User $user): self { if (!$this->users->contains($user)) { $this->users[] = $user; $user->setOrganization($this); } return $this; } public function removeUser(User $user): self { if ($this->users->contains($user)) { $this->users->removeElement($user); // set the owning side to null (unless already changed) if ($user->getOrganization() === $this) { $user->setOrganization(null); } } return $this; } }
Save File
Cancel