<?php
namespace Roothirsch\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Dkd\Populate\PopulateTrait;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Roothirsch\CoreBundle\Entity\User;
/**
* @ORM\Entity(repositoryClass="Roothirsch\CoreBundle\Repository\ContactPersonRepository")
* @ORM\Table(name="company_person")
* @ApiResource
*/
class ContactPerson
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"read", "write", "list"})
*/
private $id;
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="integer")
* @Groups({"read", "write"})
*/
private $created;
/**
* @var \DateTime
*
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="integer")
* @Groups({"read", "write"})
*/
private $updated;
/**
* @ORM\Column(type="string")
* @Assert\NotBlank()
* @Assert\Email(message="email")
* @Groups({"read", "write", "list"})
*/
private $email;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank(message="blank")
* @Groups({"read", "write", "list"})
*/
private $firstName;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank(message="blank")
* @Groups({"read", "write", "list"})
*/
private $lastName;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank(message="blank")
* @Groups({"read", "write", "list"})
*/
private $area;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank(message="blank")
* @Groups({"read", "write", "list"})
*/
private $phone;
/**
* @ORM\Column(type="string", nullable=true)
* @Assert\NotBlank(message="Dies ist ein Pflichtfeld")
* @Groups({"read", "write", "list"})
*/
private $image;
/**
* @var User[]
* @ORM\OneToMany(targetEntity="User", mappedBy="contact")
*/
private $users;
public function __toString()
{
return $this->getFullName();
}
public function getFullName()
{
return $this->getFirstName() . ' ' . $this->getLastName();
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return \DateTime
*/
public function getCreated()
{
return $this->created;
}
/**
* @param \DateTime $created
*/
public function setCreated($created)
{
$this->created = $created;
}
/**
* @return \DateTime
*/
public function getUpdated()
{
return $this->updated;
}
/**
* @param \DateTime $updated
*/
public function setUpdated($updated)
{
$this->updated = $updated;
}
/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* @param mixed $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return mixed
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param mixed $firstName
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
/**
* @return mixed
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param mixed $lastName
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
}
/**
* @return mixed
*/
public function getArea()
{
return $this->area;
}
/**
* @param mixed $area
*/
public function setArea($area)
{
$this->area = $area;
}
/**
* @return mixed
*/
public function getPhone()
{
return $this->phone;
}
/**
* @param mixed $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* @return mixed
*/
public function getImage()
{
return $this->image;
}
/**
* @param mixed $image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* @return Collection|User[]
*/
public function getUsers()
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$user->setContact($this);
$this->users[] = $user;
}
return $this;
}
public function removeUser(User $user): self
{
$user->setContact(null);
$this->users->removeElement($user);
return $this;
}
public function __construct()
{
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
}