feat: category and phone number for contacts
This commit is contained in:
@@ -9,6 +9,10 @@ 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]
|
||||
@@ -23,6 +27,10 @@ class Contact
|
||||
#[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;
|
||||
@@ -30,6 +38,11 @@ class Contact
|
||||
#[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;
|
||||
|
||||
@@ -67,6 +80,18 @@ class Contact
|
||||
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;
|
||||
@@ -91,6 +116,18 @@ class Contact
|
||||
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;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Form;
|
||||
use App\Entity\Contact;
|
||||
use App\Model\UploadSessionDto;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -21,6 +22,17 @@ class ContactType extends AbstractType
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'E-Mail',
|
||||
])
|
||||
->add('phone', TextType::class, [
|
||||
'label' => 'Telefon',
|
||||
])
|
||||
->add('category', ChoiceType::class, [
|
||||
'label' => 'Kategorie',
|
||||
'choices' => [
|
||||
'Reisemanagement' => Contact::CATEGORY_MANAGEMENT,
|
||||
'Hausmanagement' => Contact::CATEGORY_HOUSE_MANAGEMENT,
|
||||
'Personalplanung' => Contact::CATEGORY_HR,
|
||||
],
|
||||
])
|
||||
->add('destination', TextType::class, [
|
||||
'label' => 'Destination',
|
||||
'required' => false,
|
||||
|
||||
Reference in New Issue
Block a user