src/Entity/Company.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCompanyRepository::class)]
  8. class Company
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $logo null;
  18.     #[ORM\Column]
  19.     private ?\DateTimeImmutable $createdAt null;
  20.     #[ORM\OneToMany(mappedBy'company'targetEntityUser::class)]
  21.     private Collection $users;
  22.     #[ORM\OneToMany(mappedBy'company'targetEntitySeason::class)]
  23.     private Collection $seasons;
  24.     public function __toString(): string
  25.     {
  26.         return $this->getName();
  27.     }
  28.     public function __construct()
  29.     {
  30.         $this->users = new ArrayCollection();
  31.         $this->seasons = new ArrayCollection();
  32.         $this->createdAt = new \DateTimeImmutable();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getLogo(): ?string
  48.     {
  49.         return $this->logo;
  50.     }
  51.     public function setLogo(?string $logo): static
  52.     {
  53.         $this->logo $logo;
  54.         return $this;
  55.     }
  56.     public function getCreatedAt(): ?\DateTimeImmutable
  57.     {
  58.         return $this->createdAt;
  59.     }
  60.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  61.     {
  62.         $this->createdAt $createdAt;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, User>
  67.      */
  68.     public function getUsers(): Collection
  69.     {
  70.         return $this->users;
  71.     }
  72.     public function addUser(User $user): static
  73.     {
  74.         if (!$this->users->contains($user)) {
  75.             $this->users->add($user);
  76.             $user->setCompany($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeUser(User $user): static
  81.     {
  82.         if ($this->users->removeElement($user)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($user->getCompany() === $this) {
  85.                 $user->setCompany(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, Season>
  92.      */
  93.     public function getSeasons(): Collection
  94.     {
  95.         return $this->seasons;
  96.     }
  97.     public function addSeason(Season $season): static
  98.     {
  99.         if (!$this->seasons->contains($season)) {
  100.             $this->seasons->add($season);
  101.             $season->setCompany($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeSeason(Season $season): static
  106.     {
  107.         if ($this->seasons->removeElement($season)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($season->getCompany() === $this) {
  110.                 $season->setCompany(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115. }