116 lines
2.5 KiB
PHP
116 lines
2.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
|
|
{
|
|
#[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\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\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 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 getUser(): ?User
|
|
{
|
|
return $this->user;
|
|
}
|
|
|
|
public function setUser(?User $user): static
|
|
{
|
|
// unset the owning side of the relation if necessary
|
|
if ($user === null && $this->user !== null) {
|
|
$this->user->setContact(null);
|
|
}
|
|
|
|
// set the owning side of the relation if necessary
|
|
if ($user !== null && $user->getContact() !== $this) {
|
|
$user->setContact($this);
|
|
}
|
|
|
|
$this->user = $user;
|
|
|
|
return $this;
|
|
}
|
|
}
|