153 lines
3.5 KiB
PHP
153 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\ContactRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
#[ORM\Entity(repositoryClass: ContactRepository::class)]
|
|
class Contact
|
|
{
|
|
public const CATEGORY_MANAGEMENT = 'management';
|
|
public const CATEGORY_HOUSE_MANAGEMENT = 'house_management';
|
|
public const CATEGORY_HR = 'hr';
|
|
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Assert\NotBlank(message: 'Bitte gib den Namen an')]
|
|
private ?string $name = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Assert\NotBlank(message: 'Bitte gib die E-Mail-Adresse an')]
|
|
#[Assert\Email(message: 'Bitte gib eine gültige E-Mail-Adresse an', mode: 'strict')]
|
|
private ?string $email = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
#[Assert\NotBlank(message: 'Bitte gib die Telefonnummer an')]
|
|
private ?string $phone = null;
|
|
|
|
#[ORM\OneToOne(cascade: ['persist', 'remove'], fetch: 'EAGER')]
|
|
#[Assert\NotNull(message: 'Bitte lade ein Foto hoch')]
|
|
private ?Upload $photo = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $destination = null;
|
|
|
|
#[ORM\Column(length: 64)]
|
|
#[Assert\NotBlank(message: 'Bitte wähle die Kategorie')]
|
|
#[Assert\Choice(choices: [self::CATEGORY_HOUSE_MANAGEMENT, self::CATEGORY_MANAGEMENT, self::CATEGORY_HR], message: 'Die Kagegorie ist ungültig')]
|
|
private ?string $category = null;
|
|
|
|
#[ORM\OneToOne(mappedBy: 'contact', cascade: ['persist', 'remove'], fetch: 'EXTRA_LAZY')]
|
|
private ?User $user = null;
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->getName();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): static
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEmail(): ?string
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function setEmail(string $email): static
|
|
{
|
|
$this->email = $email;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPhone(): ?string
|
|
{
|
|
return $this->phone;
|
|
}
|
|
|
|
public function setPhone(?string $phone): static
|
|
{
|
|
$this->phone = $phone;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPhoto(): ?Upload
|
|
{
|
|
return $this->photo;
|
|
}
|
|
|
|
public function setPhoto(?Upload $photo): static
|
|
{
|
|
$this->photo = $photo;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getDestination(): ?string
|
|
{
|
|
return $this->destination;
|
|
}
|
|
|
|
public function setDestination(?string $destination): static
|
|
{
|
|
$this->destination = $destination;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCategory(): ?string
|
|
{
|
|
return $this->category;
|
|
}
|
|
|
|
public function setCategory(?string $category): static
|
|
{
|
|
$this->category = $category;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function setUser(?User $user): static
|
|
{
|
|
// unset the owning side of the relation if necessary
|
|
if (null === $user && null !== $this->user) {
|
|
$this->user->setContact(null);
|
|
}
|
|
|
|
// set the owning side of the relation if necessary
|
|
if (null !== $user && $user->getContact() !== $this) {
|
|
$user->setContact($this);
|
|
}
|
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
}
|
|
}
|