<?php
namespace App\Entity;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use UnzerSDK\Resources\Customer;
/**
* @ORM\Entity(repositoryClass="App\Repository\TeamRepository")
*/
class Team
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $teamName;
/**
* @ORM\Column(type="text", length=255, nullable=true)
*/
private $description;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", mappedBy="teams")
*/
private $users;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $created;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $createdBy;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="customerTeam")
*/
private $customers;
public function __toString()
{
return $this->teamName;
}
public function __construct()
{
$this->users = new ArrayCollection();
$this->created = new DateTime();
$this->customers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTeamName(): ?string
{
return $this->teamName;
}
public function setTeamName(string $teamName): self
{
$this->teamName = $teamName;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addTeam($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeTeam($this);
}
return $this;
}
public function getCreated(): ?DateTimeInterface
{
return $this->created;
}
public function setCreated(DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
/**
* @return Collection|Customer[]
*/
public function getCustomers(): Collection
{
return $this->customers;
}
public function addCustomer(User $customer): self
{
if (!$this->customers->contains($customer)) {
$this->customers[] = $customer;
$customer->setCustomerTeam($this);
}
return $this;
}
public function removeCustomer(User $customer): self
{
if ($this->customers->contains($customer)) {
$this->customers->removeElement($customer);
// set the owning side to null (unless already changed)
if ($customer->getCustomerTeam() === $this) {
$customer->setCustomerTeam(null);
}
}
return $this;
}
public function getCreatedBy(): ?int
{
return $this->createdBy;
}
public function setCreatedBy(int $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
}