src/Entity/Team.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateTimeInterface;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use UnzerSDK\Resources\Customer;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\TeamRepository")
  11.  */
  12. class Team
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $teamName;
  24.     /**
  25.      * @ORM\Column(type="text", length=255, nullable=true)
  26.      */
  27.     private $description;
  28.     /**
  29.      * @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="teams")
  30.      */
  31.     private $users;
  32.     /**
  33.      * @ORM\Column(type="datetime", nullable=true)
  34.      */
  35.     private $created;
  36.     /**
  37.      * @ORM\Column(type="integer", nullable=true)
  38.      */
  39.     private $createdBy;
  40.     /**
  41.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="customerTeam")
  42.      */
  43.     private $customers;
  44.     public function __toString()
  45.     {
  46.         return $this->teamName;
  47.     }
  48.     public function __construct()
  49.     {
  50.         $this->users = new ArrayCollection();
  51.         $this->created = new DateTime();
  52.         $this->customers = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getTeamName(): ?string
  59.     {
  60.         return $this->teamName;
  61.     }
  62.     public function setTeamName(string $teamName): self
  63.     {
  64.         $this->teamName $teamName;
  65.         return $this;
  66.     }
  67.     public function getDescription(): ?string
  68.     {
  69.         return $this->description;
  70.     }
  71.     public function setDescription(?string $description): self
  72.     {
  73.         $this->description $description;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection|User[]
  78.      */
  79.     public function getUsers(): Collection
  80.     {
  81.         return $this->users;
  82.     }
  83.     public function addUser(User $user): self
  84.     {
  85.         if (!$this->users->contains($user)) {
  86.             $this->users[] = $user;
  87.             $user->addTeam($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeUser(User $user): self
  92.     {
  93.         if ($this->users->contains($user)) {
  94.             $this->users->removeElement($user);
  95.             $user->removeTeam($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function getCreated(): ?DateTimeInterface
  100.     {
  101.         return $this->created;
  102.     }
  103.     public function setCreated(DateTimeInterface $created): self
  104.     {
  105.         $this->created $created;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection|Customer[]
  110.      */
  111.     public function getCustomers(): Collection
  112.     {
  113.         return $this->customers;
  114.     }
  115.     public function addCustomer(User $customer): self
  116.     {
  117.         if (!$this->customers->contains($customer)) {
  118.             $this->customers[] = $customer;
  119.             $customer->setCustomerTeam($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeCustomer(User $customer): self
  124.     {
  125.         if ($this->customers->contains($customer)) {
  126.             $this->customers->removeElement($customer);
  127.             // set the owning side to null (unless already changed)
  128.             if ($customer->getCustomerTeam() === $this) {
  129.                 $customer->setCustomerTeam(null);
  130.             }
  131.         }
  132.         return $this;
  133.     }
  134.     public function getCreatedBy(): ?int
  135.     {
  136.         return $this->createdBy;
  137.     }
  138.     public function setCreatedBy(int $createdBy): self
  139.     {
  140.         $this->createdBy $createdBy;
  141.         return $this;
  142.     }
  143. }